// ---------------------------------------------------------------------- // // HBookColumnLess.cc -- define the comparator class to order columns // withing a block for HBook. #include "HepTuple/Column.h" #include "HepTuple/HBookColumnLess.h" ZM_BEGIN_NAMESPACE( zmht ) /* namespace zmht { */ // First the index columns (in theory there could be several but in // the actual hbook implementation it seems limited to one) // Then all the other columns ordered by size of it elements. // This is to insure that all the column are going to be properly // aligned. We also need to verify that the first byte of the // array allocated for the data will give us this alignement. // It means that if there is no index, it should be aligned for // a double and if not we should make sure that the first non index // column is aligned for double. bool HBookColumnLess::operator()(const Column* x, const Column* y) const { if ( x->isIndex() ) { if ( y->isIndex() ) { // we assume all index are the same size return ( x->name() < y->name() ); } return true; } if ( y->isIndex() ) { // x is NOT an index (cf above) return false; } if ( x->sizeofSingleElem() > y->sizeofSingleElem() ) { return true; } if ( x->sizeofSingleElem() == y->sizeofSingleElem() ) { return( x->name() < y->name() ); } return false; } ZM_END_NAMESPACE( zmht ) /* } // namespace zmht */