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