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