Simple convenient iterator class for LCCollections that saves some boiler plate code. More...
#include <UTIL/LCIterator.h>
Public Member Functions | |
LCIterator (EVENT::LCEvent *evt, const std::string &name) | |
Constructor that reads the collection with the given name from the event - note: no exception is thrown if the collection is not in the event, this will behave the same as an empty collection - use operator() to test, if the collection exists. | |
LCIterator (EVENT::LCCollection *col) | |
Constructor for the given collection. | |
T * | next () |
Returns the next element as long as there is one, otherwise 0 is returned. | |
int | size () |
Size of the collection. | |
EVENT::LCCollection * | operator-> () |
Serves as a handle to the LCCollection itself, to provide access to the collection parameters etc. | |
EVENT::LCCollection * | operator() () |
Return pointer to LCCollection, e.g. More... | |
Simple convenient iterator class for LCCollections that saves some boiler plate code.
LCIterators can be constructed either form an LCCollection or from the LCEvent and and a collection name.
Examples:
// ------ use with while(): LCIterator<TrackerHit> it( evt, "VXDCollection" ) ; while( TrackerHit* hit = it.next() ){
hitMap[ hit->getCellID0() ] = hit ; }
// --- with for() : for( LCIterator<Track> it( col ) ; Track* trk = it.next() ; ) {
std::cout << trk->getTrackState( TrackState::AtIP ) << std::endl ; }
|
inline |
Return pointer to LCCollection, e.g.
for testing whether the collections was in the event.