#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 30 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. |
|
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 35 of file NTupleSorter.cxx. |
|
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 27 of file NTupleSorter.cxx. |
|
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 75 of file NTupleSorter.h. |
|
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 115 of file NTupleSorter.cxx. References NTuple::getColumn(), NTuple::insertRow(), std::lower_bound(), m_column, m_increasing, and m_ntuple. Referenced by sort(). |
|
Clears the NTuple.
Definition at line 108 of file NTupleSorter.cxx. References NTuple::clear(), and m_ntuple. Referenced by PickTable::clear(), and sort(). |
|
Returns the number of columns of the NTuple.
Definition at line 143 of file NTupleSorter.cxx. References DataSource::columns(), and m_ntuple. |
|
Erases a row from the NTuple. Removes the row index from the NTuple.
Definition at line 136 of file NTupleSorter.cxx. References m_ntuple. Referenced by PickTable::deleteSelectedItem(). |
|
Returns the NTuple being managed by the sorter.
Definition at line 44 of file NTupleSorter.cxx. References m_ntuple. |
|
Returns a reference to the index row of the sorted NTuple.
Definition at line 157 of file NTupleSorter.cxx. References NTuple::getRow(), and m_ntuple. Referenced by PickTable::refreshItems(), and rowwiseCopy(). |
|
A predicate function to be used for comparing two rows.
Returns Definition at line 77 of file NTupleSorter.cxx. References m_column, and m_increasing. |
|
Private assignment operator to prevent copying.
|
|
Returns the number of rows of the NTuple.
Definition at line 150 of file NTupleSorter.cxx. References m_ntuple, and NTuple::rows(). Referenced by PickTable::refreshItems(), and rowwiseCopy(). |
|
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 63 of file NTupleSorter.cxx. References getRow(), m_ntuple, and rows(). Referenced by sort(). |
|
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 51 of file NTupleSorter.cxx. References m_column, and m_increasing. |
|
Sorts the NTuple.
Definition at line 88 of file NTupleSorter.cxx. References addRow(), clear(), m_ntuple, NTuple::notifyObservers(), rowwiseCopy(), and std::sort(). |
|
The column used for sorting, or -1 if sorting is disabled.
Definition at line 41 of file NTupleSorter.h. Referenced by addRow(), operator()(), and setSorting(). |
|
The direction of the sort.
Definition at line 45 of file NTupleSorter.h. Referenced by addRow(), operator()(), and setSorting(). |
|
The NTuple object that will be used.
Definition at line 49 of file NTupleSorter.h. Referenced by addRow(), clear(), columns(), eraseRow(), getNTuple(), getRow(), rows(), rowwiseCopy(), and sort(). |