ATLAS Offline Software
|
The IdentifierToHash table. More...
#include <IdentifierToHash.h>
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, NFIELDS > | ArrayType |
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 | |
T | m_idFields |
unsigned int | m_entries |
ArrayType | m_data |
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.
typedef MultiDimArray<T,NFIELDS> IdentifierToHash< T >::ArrayType |
define type ArrayType
Definition at line 60 of file IdentifierToHash.h.
typedef T::HashType IdentifierToHash< T >::HashType |
define type HashType
Definition at line 58 of file IdentifierToHash.h.
typedef T::IdentifierType IdentifierToHash< T >::IdType |
define type IdType
Definition at line 56 of file IdentifierToHash.h.
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.
|
inline |
Default constructor makes empty hash table and creates default idFields object.
Definition at line 189 of file IdentifierToHash.h.
|
inlineexplicit |
Make empty table and initialise with idFields object.
Definition at line 194 of file IdentifierToHash.h.
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.
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).
|
inline |
Clear the hashtable.
Definition at line 257 of file IdentifierToHash.h.
|
inlinestatic |
Helper function to get a properly initialised hash.
Definition at line 62 of file IdentifierToHash.h.
|
inline |
Dump complete table to output stream.
Definition at line 287 of file IdentifierToHash.h.
|
inline |
Dump one entry for given id to os.
Definition at line 274 of file IdentifierToHash.h.
|
inline |
Dump one entry for given id to a string.
Definition at line 281 of file IdentifierToHash.h.
|
inline |
|
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.
|
inline |
|
inline |
Total number of hashes in the table.
Definition at line 269 of file IdentifierToHash.h.
|
private |
Definition at line 192 of file IdentifierToHash.h.
|
private |
Definition at line 191 of file IdentifierToHash.h.
|
mutableprivate |
Definition at line 190 of file IdentifierToHash.h.