#include <IndexSet.h>
Public Member Functions | |
void | clear () |
Clear the set. More... | |
bool | empty () const |
Check if the set is empty. More... | |
bool | has (unsigned int index) const |
Check if an element (=index) is in the set. More... | |
IndexSet () | |
Construct empty set. More... | |
void | insert (unsigned int index) |
Insert an element (=index) to the set. More... | |
void | reserve (unsigned int size) |
Reserve memory for the set. More... | |
unsigned int | size () const |
Number of elements in the set. More... | |
Private Attributes | |
std::vector< bool > | content_ |
unsigned int | numTrueElements_ |
Each possible element of the set corresponds an index in this vector. The value of an element tells if that index exists in the set (true) or not (false). More... | |
A simple class representing a set of indices to another container for fast insert and search.
This class can be useful if one needs to record the indices of objects that form a subset of a container (e.g. passing some selection), and then repeatedly check if an object of a given index belongs to that subset. As the elements are assumed to be indices, the set can be implemented as a vector<bool> such that each possible element corresponds an index in the vector. Then the insert and search are (almost) array access operations.
From the set opreations, only insertion, search, and clear are supported for now. More can be added if needed.
Definition at line 22 of file IndexSet.h.
|
inline |
Construct empty set.
Definition at line 25 of file IndexSet.h.
|
inline |
Clear the set.
Definition at line 41 of file IndexSet.h.
References content_, ntuplemaker::fill, and numTrueElements_.
|
inline |
Check if the set is empty.
Definition at line 28 of file IndexSet.h.
References numTrueElements_.
|
inline |
Check if an element (=index) is in the set.
Definition at line 54 of file IndexSet.h.
References content_.
Referenced by QuickTrackAssociatorByHitsImpl::associateTrack().
|
inline |
Insert an element (=index) to the set.
Definition at line 47 of file IndexSet.h.
References content_, numTrueElements_, and reserve().
|
inline |
Reserve memory for the set.
Definition at line 34 of file IndexSet.h.
References content_, and size().
Referenced by associationMapFilterValues(), and insert().
|
inline |
Number of elements in the set.
Definition at line 31 of file IndexSet.h.
References numTrueElements_.
Referenced by ntupleDataFormat._Collection::__iter__(), ntupleDataFormat._Collection::__len__(), and reserve().
|
private |
|
private |