BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Public Types | Public Member Functions | Private Attributes
GMAD::FastList< T > Class Template Reference

List with Efficient Lookup. More...

#include <fastlist.h>

Collaboration diagram for GMAD::FastList< T >:
Collaboration graph

Public Types

using FastListIterator = typename std::list< T >::iterator
 for ease of reading More...
 
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. More...
 
int size () const
 size of list More...
 
void clear ()
 empty lists More...
 
std::vector< T > getVector () const
 Get a vector version of this list. More...
 
FastMapIteratorPair equal_range (std::string name)
 
FastMapConstIteratorPair equal_range (std::string name) const
 
void print (int ident=0) const
 print method More...
 
template<typename FastListInputIterator >
FastListIterator insert (FastListInputIterator position, const T &val)
 template definitions need to be in header More...
 
template<typename FastListInputIterator >
void insert (FastListConstIterator position, FastListInputIterator first, const FastListInputIterator last)
 template definitions need to be in header More...
 
void erase ()
 erase elements More...
 
FastListConstIterator erase (const FastListConstIterator position)
 erase elements
 
FastListConstIterator erase (const FastListConstIterator first, const FastListConstIterator last)
 erase elements More...
 
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, FastListIteratoritsMap
 multimap for name lookup More...
 

Detailed Description

template<typename T>
class GMAD::FastList< T >

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

Author
Jochem Snuverink

Definition at line 42 of file fastlist.h.

Member Typedef Documentation

◆ FastListConstIterator

template<typename T >
using GMAD::FastList< T >::FastListConstIterator = typename std::list<T>::const_iterator

Definition at line 47 of file fastlist.h.

◆ FastListIterator

template<typename T >
using GMAD::FastList< T >::FastListIterator = typename std::list<T>::iterator

for ease of reading

Definition at line 46 of file fastlist.h.

◆ FastMapConstIterator

template<typename T >
using GMAD::FastList< T >::FastMapConstIterator = typename std::multimap<std::string, FastListIterator>::const_iterator

Definition at line 49 of file fastlist.h.

◆ FastMapConstIteratorPair

template<typename T >
using GMAD::FastList< T >::FastMapConstIteratorPair = std::pair<FastMapConstIterator,FastMapConstIterator>

Definition at line 51 of file fastlist.h.

◆ FastMapIterator

template<typename T >
using GMAD::FastList< T >::FastMapIterator = typename std::multimap<std::string, FastListIterator>::iterator

Definition at line 48 of file fastlist.h.

◆ FastMapIteratorPair

template<typename T >
using GMAD::FastList< T >::FastMapIteratorPair = std::pair<FastMapIterator,FastMapIterator>

Definition at line 50 of file fastlist.h.

Member Function Documentation

◆ begin() [1/2]

template<typename T >
FastList< T >::FastListIterator GMAD::FastList< T >::begin

non-const begin/end iterator:

Definition at line 215 of file fastlist.h.

Referenced by BDSDetectorConstruction::BuildBeamline(), and GMAD::FastList< T >::getVector().

Here is the caller graph for this function:

◆ begin() [2/2]

template<typename T >
FastList< T >::FastListConstIterator GMAD::FastList< T >::begin

const begin/end iterator:

Definition at line 225 of file fastlist.h.

◆ clear()

template<typename T >
void GMAD::FastList< T >::clear

empty lists

Definition at line 169 of file fastlist.h.

◆ empty()

template<typename T >
bool GMAD::FastList< T >::empty ( ) const
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().

Here is the caller graph for this function:

◆ end() [1/2]

template<typename T >
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::FindAndExtend(), and GMAD::FastList< T >::getVector().

Here is the caller graph for this function:

◆ end() [2/2]

template<typename T >
FastList< T >::FastListConstIterator GMAD::FastList< T >::end

const begin/end iterator:

Definition at line 230 of file fastlist.h.

◆ equal_range() [1/2]

template<typename T >
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.

◆ equal_range() [2/2]

template<typename T >
FastList< T >::FastMapConstIteratorPair GMAD::FastList< T >::equal_range ( std::string  name) const

Definition at line 240 of file fastlist.h.

◆ erase() [1/2]

template<typename T >
void GMAD::FastList< T >::erase

erase elements

Definition at line 175 of file fastlist.h.

Referenced by GMAD::FastList< T >::find().

Here is the caller graph for this function:

◆ erase() [2/2]

template<typename T >
FastList< T >::FastListConstIterator GMAD::FastList< T >::erase ( const FastListConstIterator  first,
const FastListConstIterator  last 
)

erase elements

Definition at line 205 of file fastlist.h.

◆ find() [1/2]

template<typename T >
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().

Here is the call graph for this function:

◆ find() [2/2]

template<typename T >
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 GMAD::Parser::FindAndExtend().

Here is the caller graph for this function:

◆ getVector()

template<typename T >
std::vector< T > GMAD::FastList< T >::getVector ( ) const
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().

Here is the call graph for this function:

◆ insert() [1/2]

template<typename T >
template<typename FastListInputIterator >
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().

Here is the call graph for this function:

◆ insert() [2/2]

template<typename T >
template<typename FastListInputIterator >
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::FastList< T >::insert().

Here is the caller graph for this function:

◆ insert_before()

template<typename T >
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.

◆ print()

template<typename T >
void GMAD::FastList< T >::print ( int  ident = 0) const

print method

Definition at line 287 of file fastlist.h.

◆ push_back()

template<typename T >
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.

◆ size()

template<typename T >
int GMAD::FastList< T >::size

size of list

Definition at line 164 of file fastlist.h.

Referenced by BDSDetectorConstruction::BuildBeamline().

Here is the caller graph for this function:

Field Documentation

◆ itsList

template<typename T >
std::list<T> GMAD::FastList< T >::itsList
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().

◆ itsMap

template<typename T >
std::multimap<std::string, FastListIterator> GMAD::FastList< T >::itsMap
private

multimap for name lookup

Definition at line 109 of file fastlist.h.


The documentation for this class was generated from the following files: