#include <NTupleSorter.h>
Collaboration diagram for NTupleSorter:
A class to maintain a sorted NTuple. Sorting is done by the value of elements in the selected column.
Definition at line 32 of file NTupleSorter.h.
Public Member Functions | |
void | addRow (const std::vector< double > &row) |
Adds a row to the NTuple. | |
void | clear () |
Clears the NTuple. | |
unsigned int | columns () const |
Returns the number of columns of the NTuple. | |
virtual void | eraseRow (unsigned int index) |
Erases a row from the NTuple. | |
NTuple * | getNTuple () const |
Returns the NTuple being managed by the sorter. | |
const std::vector< double > & | getRow (unsigned int index) const |
Returns a reference to the index row of the sorted NTuple. | |
NTupleSorter (NTuple *ntuple) | |
A constructor taking the NTuple to be sorted as the parameter. | |
NTupleSorter (const NTupleSorter &) | |
The copy constructor. | |
bool | operator() (std::vector< double > *x, std::vector< double > *y) const |
A predicate function to be used for comparing two rows. | |
unsigned int | rows () const |
Returns the number of rows of the NTuple. | |
void | setSorting (int column) |
Sets the sorting column. | |
void | sort () |
Sorts the NTuple. | |
virtual | ~NTupleSorter () |
The virtual destructor. | |
Private Member Functions | |
NTupleSorter & | operator= (const NTupleSorter &) |
Private assignment operator to prevent copying. | |
void | rowwiseCopy (std::vector< std::vector< double > * > &row_copy) |
Makes a row-wise copy of the NTuple object. | |
Private Attributes | |
int | m_column |
The column used for sorting, or -1 if sorting is disabled. | |
bool | m_increasing |
The direction of the sort. | |
NTuple * | m_ntuple |
The NTuple object that will be used. |
NTupleSorter | ( | const NTupleSorter & | ) |
The copy constructor.
Initializes the newly constructed object with save value of the data members except for m_ntuple which is set to null pointer. It is intended that the copy only be used as predicate to the STL sort function.
Definition at line 37 of file NTupleSorter.cxx.
NTupleSorter | ( | NTuple * | ntuple | ) |
A constructor taking the NTuple to be sorted as the parameter.
Constructs the object and initialize it to sort column 0 in increasing order. Does not sort the NTuple object.
Definition at line 29 of file NTupleSorter.cxx.
virtual ~NTupleSorter | ( | ) | [inline, virtual] |
The virtual destructor.
The virtual distructor which is needed only to avoid warning from some compilers such as Gcc 4.0.0.
Definition at line 77 of file NTupleSorter.h.
void addRow | ( | const std::vector< double > & | row | ) |
Adds a row to the NTuple.
Adds a row to the NTuple object. Maintains the sorted order with the current sorting column and its direction.
Definition at line 117 of file NTupleSorter.cxx.
References NTuple::getColumn(), NTuple::insertRow(), NTupleSorter::m_column, NTupleSorter::m_increasing, and NTupleSorter::m_ntuple.
Referenced by NTupleSorter::sort().
void clear | ( | ) |
Clears the NTuple.
Definition at line 110 of file NTupleSorter.cxx.
References NTuple::clear(), and NTupleSorter::m_ntuple.
Referenced by PickTable::clear(), and NTupleSorter::sort().
unsigned int columns | ( | ) | const |
Returns the number of columns of the NTuple.
Definition at line 145 of file NTupleSorter.cxx.
References DataSource::columns(), and NTupleSorter::m_ntuple.
void eraseRow | ( | unsigned int | index | ) | [virtual] |
Erases a row from the NTuple.
Removes the row index from the NTuple.
Definition at line 138 of file NTupleSorter.cxx.
References NTupleSorter::m_ntuple.
Referenced by PickTable::deleteSelectedItem().
NTuple * getNTuple | ( | ) | const |
Returns the NTuple being managed by the sorter.
Definition at line 46 of file NTupleSorter.cxx.
References NTupleSorter::m_ntuple.
const vector< double > & getRow | ( | unsigned int | index | ) | const |
Returns a reference to the index row of the sorted NTuple.
Definition at line 159 of file NTupleSorter.cxx.
References NTuple::getRow(), and NTupleSorter::m_ntuple.
Referenced by PickTable::refreshItems(), and NTupleSorter::rowwiseCopy().
bool operator() | ( | std::vector< double > * | x, | |
std::vector< double > * | y | |||
) | const |
A predicate function to be used for comparing two rows.
Returns true
if the element of the column used for sorting of row x is less than the element of row y.
Definition at line 79 of file NTupleSorter.cxx.
References NTupleSorter::m_column, and NTupleSorter::m_increasing.
NTupleSorter& operator= | ( | const NTupleSorter & | ) | [private] |
Private assignment operator to prevent copying.
unsigned int rows | ( | ) | const |
Returns the number of rows of the NTuple.
Definition at line 152 of file NTupleSorter.cxx.
References NTupleSorter::m_ntuple, and NTuple::rows().
Referenced by PickTable::refreshItems(), and NTupleSorter::rowwiseCopy().
void rowwiseCopy | ( | std::vector< std::vector< double > * > & | row_copy | ) | [private] |
Makes a row-wise copy of the NTuple object.
Clears the vector row_copy and fills it with a pointers to vectors containing the elements of each row.
Definition at line 65 of file NTupleSorter.cxx.
References NTupleSorter::getRow(), NTupleSorter::m_ntuple, and NTupleSorter::rows().
Referenced by NTupleSorter::sort().
void setSorting | ( | int | column | ) |
Sets the sorting column.
Sets the sorting column and resets the direction. If column is different from the current one, sets the sorting direction to be increasing. If column is the same as previously used, toggles the sorting direction to be the opposite of the current state.
Definition at line 53 of file NTupleSorter.cxx.
References NTupleSorter::m_column, and NTupleSorter::m_increasing.
void sort | ( | ) |
Sorts the NTuple.
Definition at line 90 of file NTupleSorter.cxx.
References NTupleSorter::addRow(), NTupleSorter::clear(), NTupleSorter::m_ntuple, NTuple::notifyObservers(), and NTupleSorter::rowwiseCopy().
Referenced by ContourPointRep::drawProjectedValues().
int m_column [private] |
The column used for sorting, or -1 if sorting is disabled.
Definition at line 43 of file NTupleSorter.h.
Referenced by NTupleSorter::addRow(), NTupleSorter::operator()(), and NTupleSorter::setSorting().
bool m_increasing [private] |
The direction of the sort.
Definition at line 47 of file NTupleSorter.h.
Referenced by NTupleSorter::addRow(), NTupleSorter::operator()(), and NTupleSorter::setSorting().
The NTuple object that will be used.
Definition at line 51 of file NTupleSorter.h.
Referenced by NTupleSorter::addRow(), NTupleSorter::clear(), NTupleSorter::columns(), NTupleSorter::eraseRow(), NTupleSorter::getNTuple(), NTupleSorter::getRow(), NTupleSorter::rows(), NTupleSorter::rowwiseCopy(), and NTupleSorter::sort().