24 using std::lower_bound;
31 m_increasing ( true ),
38 : m_column ( sorter.m_column ),
39 m_increasing ( sorter.m_increasing ),
65 rowwiseCopy ( std::vector < std::vector < double > * > & row_copy )
70 for (
unsigned int row = 0; row <
rows; row++ ) {
72 vector < double > * p =
new vector < double > ( v );
73 row_copy.push_back ( p );
80 std::vector < double > * y )
const
82 double left = x -> operator[] (
m_column );
83 double right = y -> operator[] (
m_column );
92 vector < vector < double > * > table;
95 std::sort ( table.begin(), table.end(), *this );
99 vector < vector < double > * > :: iterator first = table.begin ();
100 while ( first != table.end () ) {
101 vector < double > * p = *first++;
117 addRow (
const std::vector < double > & row )
122 vector < double > ::const_iterator first;
125 first = lower_bound ( column.begin(), column.end(), sort_value );
128 first = lower_bound ( column.begin(), column.end(),
129 sort_value, greater< double >() );
131 unsigned int index = distance ( column.begin(), first );
157 const vector < double > &
column
The column indices for 2 dimension data point tuple.
virtual unsigned int rows() const
Returns the number of rows.
bool operator()(std::vector< double > *x, std::vector< double > *y) const
A predicate function to be used for comparing two rows.
unsigned int columns() const
Returns the number of columns of the NTuple.
NTuple * getNTuple() const
Returns the NTuple being managed by the sorter.
virtual const std::vector< double > & getRow(unsigned int index) const
Returns a temporary vector of data elements in one row.
NTuple * m_ntuple
The NTuple object that will be used.
NTupleSorter class interface.
void rowwiseCopy(std::vector< std::vector< double > * > &row_copy)
Makes a row-wise copy of the NTuple object.
virtual void clear()
Clears the NTuple.
void setSorting(int column)
Sets the sorting column.
A DataSource class implemented with std::vector to store the column data. ...
virtual void notifyObservers() const
Notifies Observer objects of a change.
hippodraw::NTuple class interface.
A helper class to sort and keep sorted an NTuple.
void clear()
Clears the NTuple.
virtual const std::vector< double > & getColumn(unsigned int index) const
Returns the data in the column with index column.
unsigned int columns() const
Returns the number of columns or data arrays available from this DataSource.
virtual void eraseRow(unsigned int index)
Erases a row from the NTuple.
void sort()
Sorts the NTuple.
void addRow(const std::vector< double > &row)
Adds a row to the NTuple.
bool m_increasing
The direction of the sort.
virtual void insertRow(unsigned int index, const std::vector< double > &v)
Inserts a Row.
int m_column
The column used for sorting, or -1 if sorting is disabled.
NTupleSorter(const NTupleSorter &)
The copy constructor.
unsigned int rows() const
Returns the number of rows of the NTuple.
const std::vector< double > & getRow(unsigned int index) const
Returns a reference to the index row of the sorted NTuple.