24 using std::lower_bound;
31 m_increasing ( true ),
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 > &
virtual unsigned int rows() const
Returns the number of rows.
void setSorting(int column)
Sets the sorting column.
bool operator()(std::vector< double > *x, std::vector< double > *y) const
A predicate function to be used for comparing two rows.
void sort()
Sorts the NTuple.
virtual const std::vector< double > & getColumn(unsigned int index) const
Returns the data in the column with index column.
virtual void insertRow(unsigned int index, const std::vector< double > &v)
Inserts a Row.
unsigned int rows() const
Returns the number of rows of the NTuple.
NTupleSorter class interface.
unsigned int columns() const
Returns the number of columns or data arrays available from this DataSource.
bool m_increasing
The direction of the sort.
hippodraw::NTuple class interface.
void clear()
Clears the NTuple.
virtual const std::vector< double > & getRow(unsigned int index) const
Returns a temporary vector of data elements in one row.
int m_column
The column used for sorting, or -1 if sorting is disabled.
NTuple * getNTuple() const
Returns the NTuple being managed by the sorter.
void rowwiseCopy(std::vector< std::vector< double > * > &row_copy)
Makes a row-wise copy of the NTuple object.
A DataSource class implemented with std::vector<double> to store the column data. ...
virtual void clear()
Clears the NTuple.
virtual void eraseRow(unsigned int index)
Erases a row from the NTuple.
unsigned int columns() const
Returns the number of columns of the NTuple.
void addRow(const std::vector< double > &row)
Adds a row to the NTuple.
virtual void notifyObservers() const
Notifies Observer objects of a change.
NTupleSorter(const NTupleSorter &)
The copy constructor.
A helper class to sort and keep sorted an NTuple.
const std::vector< double > & getRow(unsigned int index) const
Returns a reference to the index row of the sorted NTuple.
NTuple * m_ntuple
The NTuple object that will be used.
column
The column indices for 2 dimension data point tuple.