Geant4-11
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
G4MapCache< KEYTYPE, VALTYPE > Class Template Reference

#include <G4Cache.hh>

Inheritance diagram for G4MapCache< KEYTYPE, VALTYPE >:
G4Cache< std::map< KEYTYPE, VALTYPE > >

Public Types

typedef map_type::const_iterator const_iterator
 
typedef map_type::iterator iterator
 
typedef KEYTYPE key_type
 
typedef std::map< key_type, value_typemap_type
 
typedef map_type::size_type size_type
 
typedef VALTYPE value_type
 

Public Member Functions

iterator Begin ()
 
iterator End ()
 
size_type Erase (const key_type &k)
 
iterator Find (const key_type &k)
 
value_typeGet () const
 
value_typeGet (const key_type &k)
 
G4bool Has (const key_type &k)
 
std::pair< iterator, G4boolInsert (const key_type &k, const value_type &v)
 
value_typeoperator[] (const key_type &k)
 
value_type Pop ()
 
void Put (const value_type &val) const
 
size_type Size ()
 
virtual ~G4MapCache ()
 

Protected Member Functions

const G4intGetId () const
 

Private Member Functions

value_typeGetCache () const
 

Private Attributes

G4int id
 
G4CacheReference< value_typetheCache
 

Static Private Attributes

static std::atomic< unsigned int > dstrctr
 
static std::atomic< unsigned int > instancesctr
 

Detailed Description

template<class KEYTYPE, class VALTYPE>
class G4MapCache< KEYTYPE, VALTYPE >

Definition at line 175 of file G4Cache.hh.

Member Typedef Documentation

◆ const_iterator

template<class KEYTYPE , class VALTYPE >
typedef map_type::const_iterator G4MapCache< KEYTYPE, VALTYPE >::const_iterator

Definition at line 185 of file G4Cache.hh.

◆ iterator

template<class KEYTYPE , class VALTYPE >
typedef map_type::iterator G4MapCache< KEYTYPE, VALTYPE >::iterator

Definition at line 184 of file G4Cache.hh.

◆ key_type

template<class KEYTYPE , class VALTYPE >
typedef KEYTYPE G4MapCache< KEYTYPE, VALTYPE >::key_type

Definition at line 180 of file G4Cache.hh.

◆ map_type

template<class KEYTYPE , class VALTYPE >
typedef std::map<key_type, value_type> G4MapCache< KEYTYPE, VALTYPE >::map_type

Definition at line 182 of file G4Cache.hh.

◆ size_type

template<class KEYTYPE , class VALTYPE >
typedef map_type::size_type G4MapCache< KEYTYPE, VALTYPE >::size_type

Definition at line 183 of file G4Cache.hh.

◆ value_type

template<class KEYTYPE , class VALTYPE >
typedef VALTYPE G4MapCache< KEYTYPE, VALTYPE >::value_type

Definition at line 181 of file G4Cache.hh.

Constructor & Destructor Documentation

◆ ~G4MapCache()

template<class K , class V >
G4MapCache< K, V >::~G4MapCache
virtual

Definition at line 423 of file G4Cache.hh.

424{
425#ifdef g4cdebug
426 std::cout << "~G4MacCache " << G4Cache<map_type>::GetId()
427 << " with size: " << Size() << "->";
428 for(iterator it = Begin(); it != End(); ++it)
429 std::cout << it->first << ":" << it->second << ",";
430 std::cout << "<-" << std::endl;
431#endif
432}
const G4int & GetId() const
Definition: G4Cache.hh:116
map_type::iterator iterator
Definition: G4Cache.hh:184
iterator Begin()
Definition: G4Cache.hh:448
iterator End()
Definition: G4Cache.hh:453
size_type Size()
Definition: G4Cache.hh:203

References G4Cache< VALTYPE >::GetId().

Member Function Documentation

◆ Begin()

template<class K , class V >
G4MapCache< K, V >::iterator G4MapCache< K, V >::Begin
inline

Definition at line 448 of file G4Cache.hh.

449{
450 return G4Cache<map_type>::Get().begin();
451}
value_type & Get() const
Definition: G4Cache.hh:315

References G4Cache< VALTYPE >::Get().

◆ End()

template<class K , class V >
G4MapCache< K, V >::iterator G4MapCache< K, V >::End
inline

Definition at line 453 of file G4Cache.hh.

454{
455 return G4Cache<map_type>::Get().end();
456}

References G4Cache< VALTYPE >::Get().

Referenced by G4VBiasingOperator::AttachTo(), and G4VBiasingOperator::GetBiasingOperator().

◆ Erase()

template<class KEYTYPE , class VALTYPE >
G4MapCache< K, V >::size_type G4MapCache< K, V >::Erase ( const key_type k)
inline

Definition at line 477 of file G4Cache.hh.

478{
479 return G4Cache<map_type>::Get().erase(k);
480}

References G4Cache< VALTYPE >::Get().

◆ Find()

template<class KEYTYPE , class VALTYPE >
G4MapCache< K, V >::iterator G4MapCache< K, V >::Find ( const key_type k)
inline

◆ Get() [1/2]

V & G4Cache< V >::Get
inlineinherited

Definition at line 103 of file G4Cache.hh.

316{
317 return GetCache();
318}

◆ Get() [2/2]

template<class KEYTYPE , class VALTYPE >
V & G4MapCache< K, V >::Get ( const key_type k)
inline

Definition at line 471 of file G4Cache.hh.

472{
473 return Find(k)->second;
474}
iterator Find(const key_type &k)
Definition: G4Cache.hh:459

◆ GetCache()

value_type & G4Cache< std::map< KEYTYPE, VALTYPE > >::GetCache ( ) const
inlineprivateinherited

Definition at line 124 of file G4Cache.hh.

125 {
127 return theCache.GetCache(id);
128 }
VALTYPE & GetCache(unsigned int id) const
void Initialize(unsigned int id)
G4CacheReference< value_type > theCache
Definition: G4Cache.hh:120

◆ GetId()

const G4int & G4Cache< std::map< KEYTYPE, VALTYPE > >::GetId ( ) const
inlineprotectedinherited

Definition at line 116 of file G4Cache.hh.

◆ Has()

template<class KEYTYPE , class VALTYPE >
G4bool G4MapCache< K, V >::Has ( const key_type k)
inline

Definition at line 465 of file G4Cache.hh.

466{
467 return (Find(k) != End());
468}

◆ Insert()

template<class KEYTYPE , class VALTYPE >
std::pair< typename G4MapCache< K, V >::iterator, G4bool > G4MapCache< K, V >::Insert ( const key_type k,
const value_type v 
)
inline

Definition at line 435 of file G4Cache.hh.

437{
438 return G4Cache<map_type>::Get().insert(std::pair<key_type, value_type>(k, v));
439}

References G4Cache< VALTYPE >::Get().

◆ operator[]()

template<class KEYTYPE , class VALTYPE >
V & G4MapCache< K, V >::operator[] ( const key_type k)
inline

Definition at line 483 of file G4Cache.hh.

484{
485 return (G4Cache<map_type>::Get())[k];
486}

◆ Pop()

V G4Cache< V >::Pop
inlineinherited

Definition at line 109 of file G4Cache.hh.

329{
330 return GetCache();
331}

◆ Put()

void G4Cache< V >::Put ( const value_type val) const
inlineinherited

Definition at line 106 of file G4Cache.hh.

322{
323 GetCache() = val;
324}

◆ Size()

template<class KEYTYPE , class VALTYPE >
size_type G4MapCache< KEYTYPE, VALTYPE >::Size ( )
inline

Definition at line 203 of file G4Cache.hh.

203{ return G4Cache<map_type>::Get().size(); }

References G4Cache< VALTYPE >::Get().

Field Documentation

◆ dstrctr

std::atomic< unsigned int > G4Cache< V >::dstrctr
staticprivateinherited

Definition at line 122 of file G4Cache.hh.

◆ id

G4int G4Cache< std::map< KEYTYPE, VALTYPE > >::id
privateinherited

Definition at line 119 of file G4Cache.hh.

◆ instancesctr

std::atomic< unsigned int > G4Cache< V >::instancesctr
staticprivateinherited

Definition at line 121 of file G4Cache.hh.

◆ theCache

G4CacheReference<value_type> G4Cache< std::map< KEYTYPE, VALTYPE > >::theCache
mutableprivateinherited

Definition at line 120 of file G4Cache.hh.


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