ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
IdentifierToHash< T > Class Template Reference

The IdentifierToHash table. More...

#include <IdentifierToHash.h>

Collaboration diagram for IdentifierToHash< T >:

Classes

class  RecursiveIndexCall
 Helper class for IdentifierToHash to automate recursive index call. More...
 
class  RecursiveIndexCall< 0, K >
 
class  RecursiveIndexCall< 1, K >
 
class  RecursiveRangeCheck
 Helper class for one-go recursive range check on all indices. More...
 
class  RecursiveRangeCheck< 0, K >
 N=0 is invalid. More...
 
class  RecursiveRangeCheck< 1, K >
 Specialise for N=1 to end recursion. More...
 

Public Types

enum  { NFIELDS = T::NFIELDS, NMAX =UINT_MAX }
 N is the number of fields to use from the identifier NMAX is just to make sure we get unsigned int type of enum. More...
 
typedef T::IdentifierType IdType
 define type IdType More...
 
typedef T::HashType HashType
 define type HashType More...
 
typedef MultiDimArray< T, NFIELDSArrayType
 define type ArrayType More...
 

Public Member Functions

 IdentifierToHash ()
 Default constructor makes empty hash table and creates default idFields object. More...
 
 IdentifierToHash (const T &idFields)
 Make empty table and initialise with idFields object. More...
 
void clear ()
 Clear the hashtable. More...
 
unsigned int size () const
 Number of valid hashes in the table. More...
 
unsigned int totalSize () const
 Total number of hashes in the table. More...
 
HashType addEntry (const IdType &id)
 Add an identifier to the table, and return the hash value belonging to it. More...
 
bool addEntry (const IdType &id, const HashType &aHash)
 Add an identifier+hash pair to the table. More...
 
HashType getHash (const IdType &id) const
 Get hash from 0 to size()-1. More...
 
void dumpOneEntry (const IdType &id, std::ostream &os) const
 Dump one entry for given id to os. More...
 
std::string dumpOneEntryToString (const IdType &id) const
 Dump one entry for given id to a string. More...
 
void dump (std::ostream &os=std::cout) const
 Dump complete table to output stream. More...
 
std::string dumpToString () const
 Dump complete table into a string. More...
 

Static Public Member Functions

static HashType defaultHashValue ()
 Helper function to get a properly initialised hash. More...
 

Private Attributes

m_idFields
 
unsigned int m_entries
 
ArrayType m_data
 

Detailed Description

template<class T>
class IdentifierToHash< T >

The IdentifierToHash table.

It uses a multi-dimensional array and identifier fields for fast access of Identifier-to-hash conversions. For hash-to-Identifier conversion it uses a one-dimensional array of Identifiers.

The template parameter is a helper class which is used to extract the fields from the identifier. This helper class must derive from class IdHashTableHelper, which is again a templated class, and also serves as a traits class (i.e. supplies some type definitions + number of fields).

Definition at line 39 of file IdentifierToHash.h.

Member Typedef Documentation

◆ ArrayType

template<class T >
typedef MultiDimArray<T,NFIELDS> IdentifierToHash< T >::ArrayType

define type ArrayType

Definition at line 60 of file IdentifierToHash.h.

◆ HashType

template<class T >
typedef T::HashType IdentifierToHash< T >::HashType

define type HashType

Definition at line 58 of file IdentifierToHash.h.

◆ IdType

template<class T >
typedef T::IdentifierType IdentifierToHash< T >::IdType

define type IdType

Definition at line 56 of file IdentifierToHash.h.

Member Enumeration Documentation

◆ anonymous enum

template<class T >
anonymous enum

N is the number of fields to use from the identifier NMAX is just to make sure we get unsigned int type of enum.

Enumerator
NFIELDS 
NMAX 

Definition at line 54 of file IdentifierToHash.h.

55 {

Constructor & Destructor Documentation

◆ IdentifierToHash() [1/2]

template<class T >
IdentifierToHash< T >::IdentifierToHash
inline

Default constructor makes empty hash table and creates default idFields object.

Definition at line 189 of file IdentifierToHash.h.

190  : m_entries(0)
191 {}

◆ IdentifierToHash() [2/2]

template<class T >
IdentifierToHash< T >::IdentifierToHash ( const T &  idFields)
inlineexplicit

Make empty table and initialise with idFields object.

Definition at line 194 of file IdentifierToHash.h.

195  : m_idFields( idFields ), m_entries(0)
196 {}

Member Function Documentation

◆ addEntry() [1/2]

template<class T >
HashType IdentifierToHash< T >::addEntry ( const IdType id)

Add an identifier to the table, and return the hash value belonging to it.

Hash values start at zero, and increase by 1 at every call to addEntry(). Returns defaultHashValue() if id is invalid or was already present.

◆ addEntry() [2/2]

template<class T >
bool IdentifierToHash< T >::addEntry ( const IdType id,
const HashType aHash 
)

Add an identifier+hash pair to the table.

Returns true if the pair was added. Multiple times the same id is not allowed, but multiple times the same hash is allowed. It is therefore the responsibility of the caller to make sure that the hashes are unique (if so desired).

◆ clear()

template<class T >
void IdentifierToHash< T >::clear
inline

Clear the hashtable.

Definition at line 257 of file IdentifierToHash.h.

258  {
259  m_entries = 0;
260  m_data.clear();

◆ defaultHashValue()

template<class T >
static HashType IdentifierToHash< T >::defaultHashValue ( )
inlinestatic

Helper function to get a properly initialised hash.

Definition at line 62 of file IdentifierToHash.h.

62  {
63  public:
64  static const typename K::ValueType& getConstRef( const K& obj, const T& indices ) {

◆ dump()

template<class T >
void IdentifierToHash< T >::dump ( std::ostream &  os = std::cout) const
inline

Dump complete table to output stream.

Definition at line 287 of file IdentifierToHash.h.

288  {
289  m_data.dump( os );

◆ dumpOneEntry()

template<class T >
void IdentifierToHash< T >::dumpOneEntry ( const IdType id,
std::ostream &  os 
) const
inline

Dump one entry for given id to os.

Definition at line 274 of file IdentifierToHash.h.

276  {
277  m_idFields.setAll( id );

◆ dumpOneEntryToString()

template<class T >
std::string IdentifierToHash< T >::dumpOneEntryToString ( const IdType id) const
inline

Dump one entry for given id to a string.

Definition at line 281 of file IdentifierToHash.h.

282  {
283  m_idFields.setAll( id );

◆ dumpToString()

template<class T >
std::string IdentifierToHash< T >::dumpToString
inline

Dump complete table into a string.

Definition at line 292 of file IdentifierToHash.h.

293  {
294  return m_data.dumpToString();

◆ getHash()

template<class T >
IdentifierToHash< T >::HashType IdentifierToHash< T >::getHash ( const IdType id) const
inline

Get hash from 0 to size()-1.

Returns invalid hash if id is not in table.

Definition at line 246 of file IdentifierToHash.h.

247  {
248  if ( !T::isValid( id ) ) return defaultHashValue();
249  m_idFields.setAll( id );
250  // check that fields are in range
252  return defaultHashValue();
253  }

◆ size()

template<class T >
unsigned int IdentifierToHash< T >::size
inline

Number of valid hashes in the table.

Definition at line 263 of file IdentifierToHash.h.

264  {
265  return m_entries;

◆ totalSize()

template<class T >
unsigned int IdentifierToHash< T >::totalSize
inline

Total number of hashes in the table.

Definition at line 269 of file IdentifierToHash.h.

270  {
271  return m_data.totalSize();

Member Data Documentation

◆ m_data

template<class T >
ArrayType IdentifierToHash< T >::m_data
private

Definition at line 192 of file IdentifierToHash.h.

◆ m_entries

template<class T >
unsigned int IdentifierToHash< T >::m_entries
private

Definition at line 191 of file IdentifierToHash.h.

◆ m_idFields

template<class T >
T IdentifierToHash< T >::m_idFields
mutableprivate

Definition at line 190 of file IdentifierToHash.h.


The documentation for this class was generated from the following file:
IdentifierToHash::m_idFields
T m_idFields
Definition: IdentifierToHash.h:190
IdentifierToHash::defaultHashValue
static HashType defaultHashValue()
Helper function to get a properly initialised hash.
Definition: IdentifierToHash.h:62
MultiDimArray::clear
void clear()
Definition: MultiDimArray.h:195
Trk::indices
std::pair< long int, long int > indices
Definition: AlSymMatBase.h:24
IdentifierToHash::RecursiveIndexCall::getConstRef
static const K::ValueType & getConstRef(const K &obj, const T &indices)
Definition: IdentifierToHash.h:71
isValid
bool isValid(const T &p)
Definition: AtlasPID.h:214
IdentifierToHash::RecursiveRangeCheck::isInRange
static bool isInRange(const K &obj, const T &indices)
Definition: IdentifierToHash.h:119
MultiDimArray::dumpOneEntryToString
std::string dumpOneEntryToString(const K &indices) const
Dump one entry with given indices into a string.
Definition: MultiDimArray.h:429
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
MultiDimArray::totalSize
unsigned int totalSize() const
The total number of elements, including invalid (=default) holes, from this field downwards.
Definition: MultiDimArray.h:348
MultiDimArray::dumpOneEntry
void dumpOneEntry(const K &indices, std::ostream &os=std::cout) const
Dump one entry with given indices to an output stream.
Definition: MultiDimArray.h:423
MultiDimArray::dump
void dump(std::ostream &os=std::cout) const
Dump the complete table to an output stream.
Definition: MultiDimArray.h:380
IdentifierToHash::m_entries
unsigned int m_entries
Definition: IdentifierToHash.h:191
MultiDimArray::dumpToString
std::string dumpToString() const
Dump the complete table into a string.
Definition: MultiDimArray.h:392
IdentifierToHash::m_data
ArrayType m_data
Definition: IdentifierToHash.h:192
python.PyAthena.obj
obj
Definition: PyAthena.py:135
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35