BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
List with Efficient Lookup. More...
#include <fastlist.h>
Public Types | |
using | FastListIterator = typename std::list< T >::iterator |
for ease of reading | |
using | FastListConstIterator = typename std::list< T >::const_iterator |
using | FastMapIterator = typename std::multimap< std::string, FastListIterator >::iterator |
using | FastMapConstIterator = typename std::multimap< std::string, FastListIterator >::const_iterator |
using | FastMapIteratorPair = std::pair< FastMapIterator, FastMapIterator > |
using | FastMapConstIteratorPair = std::pair< FastMapConstIterator, FastMapConstIterator > |
Public Member Functions | |
void | insert_before (const std::string &name, const T &val) |
void | push_back (const T &el, bool unique=false, const std::string &objectName="element") |
bool | empty () const |
Whether the list is empty. | |
int | size () const |
size of list | |
void | clear () |
empty lists | |
std::vector< T > | getVector () const |
Get a vector version of this list. | |
FastMapIteratorPair | equal_range (std::string name) |
FastMapConstIteratorPair | equal_range (std::string name) const |
void | print (int ident=0) const |
print method | |
template<typename FastListInputIterator > | |
FastListIterator | insert (FastListInputIterator position, const T &val) |
template definitions need to be in header | |
template<typename FastListInputIterator > | |
void | insert (FastListConstIterator position, FastListInputIterator first, const FastListInputIterator last) |
template definitions need to be in header | |
void | erase () |
erase elements | |
FastListConstIterator | erase (const FastListConstIterator position) |
erase elements | |
FastListConstIterator | erase (const FastListConstIterator first, const FastListConstIterator last) |
erase elements | |
FastListIterator | begin () |
FastListIterator | end () |
FastListConstIterator | begin () const |
FastListConstIterator | end () const |
FastListConstIterator | find (std::string name, unsigned int count=1) const |
FastListIterator | find (std::string name, unsigned int count=1) |
Private Attributes | |
std::list< T > | itsList |
std::multimap< std::string, FastListIterator > | itsMap |
multimap for name lookup | |
List with Efficient Lookup.
This class keeps a list of elements It has efficient lookup on an element's name (log n) by having a multimap between name and list position
Used for beamline
Definition at line 42 of file fastlist.h.
using GMAD::FastList< T >::FastListConstIterator = typename std::list<T>::const_iterator |
Definition at line 47 of file fastlist.h.
using GMAD::FastList< T >::FastListIterator = typename std::list<T>::iterator |
for ease of reading
Definition at line 46 of file fastlist.h.
using GMAD::FastList< T >::FastMapConstIterator = typename std::multimap<std::string, FastListIterator>::const_iterator |
Definition at line 49 of file fastlist.h.
using GMAD::FastList< T >::FastMapConstIteratorPair = std::pair<FastMapConstIterator,FastMapConstIterator> |
Definition at line 51 of file fastlist.h.
using GMAD::FastList< T >::FastMapIterator = typename std::multimap<std::string, FastListIterator>::iterator |
Definition at line 48 of file fastlist.h.
using GMAD::FastList< T >::FastMapIteratorPair = std::pair<FastMapIterator,FastMapIterator> |
Definition at line 50 of file fastlist.h.
FastList< T >::FastListIterator GMAD::FastList< T >::begin |
non-const begin/end iterator:
Definition at line 215 of file fastlist.h.
Referenced by BDSDetectorConstruction::BuildBeamline(), GMAD::Parser::expand_line(), and GMAD::FastList< T >::getVector().
FastList< T >::FastListConstIterator GMAD::FastList< T >::begin |
const begin/end iterator:
Definition at line 225 of file fastlist.h.
void GMAD::FastList< T >::clear |
empty lists
Definition at line 169 of file fastlist.h.
Referenced by GMAD::Parser::expand_line().
|
inline |
Whether the list is empty.
Definition at line 68 of file fastlist.h.
References GMAD::FastList< T >::itsList.
Referenced by BDSDetectorConstruction::BuildBeamline(), and BDSDetectorConstruction::BuildPhysicsBias().
FastList< T >::FastListIterator GMAD::FastList< T >::end |
non-const begin/end iterator:
Definition at line 220 of file fastlist.h.
Referenced by BDSDetectorConstruction::BuildBeamline(), GMAD::Parser::expand_line(), GMAD::Parser::FindAndExtend(), and GMAD::FastList< T >::getVector().
FastList< T >::FastListConstIterator GMAD::FastList< T >::end |
const begin/end iterator:
Definition at line 230 of file fastlist.h.
FastList< T >::FastMapIteratorPair GMAD::FastList< T >::equal_range | ( | std::string | name | ) |
lookup method, returns pair of iterators of list pointing (similar to std::multimap::equal_range)
Definition at line 235 of file fastlist.h.
FastList< T >::FastMapConstIteratorPair GMAD::FastList< T >::equal_range | ( | std::string | name | ) | const |
Definition at line 240 of file fastlist.h.
void GMAD::FastList< T >::erase |
erase elements
Definition at line 175 of file fastlist.h.
Referenced by GMAD::Parser::expand_line(), and GMAD::FastList< T >::find().
FastList< T >::FastListConstIterator GMAD::FastList< T >::erase | ( | const FastListConstIterator | first, |
const FastListConstIterator | last | ||
) |
erase elements
Definition at line 205 of file fastlist.h.
FastList< T >::FastListIterator GMAD::FastList< T >::find | ( | std::string | name, |
unsigned int | count = 1 |
||
) |
lookup method, returns iterator of list pointing to element with name second argument is instance number, default first instance both const and non-const version
Definition at line 264 of file fastlist.h.
References GMAD::FastList< T >::erase().
FastList< T >::FastListConstIterator GMAD::FastList< T >::find | ( | std::string | name, |
unsigned int | count = 1 |
||
) | const |
lookup method, returns iterator of list pointing to element with name second argument is instance number, default first instance both const and non-const version
Definition at line 245 of file fastlist.h.
Referenced by BDSDetectorConstruction::BuildCrossSectionBias(), GMAD::Parser::expand_line(), and GMAD::Parser::FindAndExtend().
|
inline |
Get a vector version of this list.
Definition at line 89 of file fastlist.h.
References GMAD::FastList< T >::begin(), and GMAD::FastList< T >::end().
void GMAD::FastList< T >::insert | ( | FastListConstIterator | position, |
FastListInputIterator | first, | ||
const FastListInputIterator | last | ||
) |
template definitions need to be in header
insert options (classic list inserts): inputiterator templated to account for reverse iterators
Definition at line 125 of file fastlist.h.
References GMAD::FastList< T >::insert().
FastList< T >::FastListIterator GMAD::FastList< T >::insert | ( | FastListInputIterator | position, |
const T & | val | ||
) |
template definitions need to be in header
insert options (classic list inserts): inputiterator templated to account for reverse iterators
Definition at line 115 of file fastlist.h.
Referenced by GMAD::Parser::expand_line(), and GMAD::FastList< T >::insert().
void GMAD::FastList< T >::insert_before | ( | const std::string & | name, |
const T & | val | ||
) |
insert element before all elements with given name exits if no element with name
Definition at line 133 of file fastlist.h.
void GMAD::FastList< T >::print | ( | int | ident = 0 | ) | const |
print method
Definition at line 287 of file fastlist.h.
void GMAD::FastList< T >::push_back | ( | const T & | el, |
bool | unique = false , |
||
const std::string & | objectName = "element" |
||
) |
insert element at end of list option to check for unique element name (exits in case name is not unique), false by default
Definition at line 152 of file fastlist.h.
Referenced by GMAD::Parser::expand_line().
int GMAD::FastList< T >::size |
size of list
Definition at line 164 of file fastlist.h.
Referenced by BDSDetectorConstruction::BuildBeamline().
|
private |
the element list a list is chosen since insertion is fast and iterators are not invalidated
Definition at line 107 of file fastlist.h.
Referenced by GMAD::FastList< T >::empty().
|
private |
multimap for name lookup
Definition at line 109 of file fastlist.h.