OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

StaticHashTable< T, Key, Hash > Class Template Reference

STL conforming hash table. More...

Collaboration diagram for StaticHashTable< T, Key, Hash >:

List of all members.


Classes

class  Iterator
 An STL iterator. More...

Public Types

typedef Iterator< T
&, StaticHashTable< T, Key,
Hash > & > 
iterator
typedef Iterator< const T
&, const StaticHashTable< T,
Key, Hash > & > 
const_iterator
typedef T value_type
 Type of values the StaticHashTable contains.
typedef T & reference
 Type that can be used for storing into StaticHashTable::value_type.
typedef const T & const_reference
 Type that can be used for storing into constant.
typedef label size_type
 The type that can represent the size of a StaticHashTable.

Public Member Functions

 StaticHashTable (const label size=128)
 Construct given initial table size.
 StaticHashTable (Istream &, const label size=128)
 Construct from Istream.
 StaticHashTable (const StaticHashTable< T, Key, Hash > &)
 Construct as copy.
 StaticHashTable (const Xfer< StaticHashTable< T, Key, Hash > > &)
 Construct by transferring the parameter contents.
 ~StaticHashTable ()
label size () const
 Return number of elements in table.
bool empty () const
 Return true if the hash table is empty.
bool found (const Key &key) const
 Return true if hashed entry is found in table.
iterator find (const Key &key)
 Find and return an iterator set at the hashed entry.
const_iterator find (const Key &key) const
 Find and return an const_iterator set at the hashed entry.
List< Key > toc () const
 Return the table of contents.
Ostream & printInfo (Ostream &) const
 Print information.
bool insert (const Key &key, const T &newElmt)
 Insert a new hashed entry.
bool set (const Key &, const T &newElmt)
 Assign a new hashed entry, overwriting existing entries.
bool erase (const iterator &it)
 Erase an hashed entry specified by given iterator.
bool erase (const Key &key)
 Erase an hashed entry specified by given key if in table.
void resize (const label newSize)
 Resize the hash table for efficiency.
label erase (const StaticHashTable< T, Key, Hash > &)
 Remove entries in the given hash table from this hash table.
void clear ()
 Clear all entries from table.
void clearStorage ()
 Clear the table entries and the table itself.
void transfer (StaticHashTable< T, Key, Hash > &)
 Transfer the contents of the argument table into this table.
Xfer< StaticHashTable< T, Key,
Hash > > 
xfer ()
 Transfer contents to the Xfer container.
T & operator[] (const Key &)
 Find and return an hashed entry.
const T & operator[] (const Key &) const
 Find and return an hashed entry.
T & operator() (const Key &)
 Find and return an hashed entry, create it null if not present.
void operator= (const StaticHashTable< T, Key, Hash > &)
 Assignment.
bool operator== (const StaticHashTable< T, Key, Hash > &) const
 Equality. Two hash tables are equal if all contents of first are.
bool operator!= (const StaticHashTable< T, Key, Hash > &) const
 The opposite of the equality operation.
iterator begin ()
 iterator set to the beginning of the StaticHashTable
const iterator & end ()
 iterator set to beyond the end of the StaticHashTable
const_iterator cbegin () const
 const_iterator set to the beginning of the StaticHashTable
const const_iterator & cend () const
 const_iterator set to beyond the end of the StaticHashTable
const_iterator begin () const
 const_iterator set to the beginning of the StaticHashTable
const const_iterator & end () const
 const_iterator set to beyond the end of the StaticHashTable

Friends

class Iterator< T &, StaticHashTable< T, Key, Hash > & >
class Iterator< const T &, const StaticHashTable< T, Key, Hash > & >
Istream & operator>> (Istream &, StaticHashTable< T, Key, Hash > &)
Ostream & operator (Ostream &, const StaticHashTable< T, Key, Hash > &)

Detailed Description

template<class T, class Key = word, class Hash = string::hash>
class Foam::StaticHashTable< T, Key, Hash >

STL conforming hash table.

Note:
Uses straight lists as underlying type. Is slower to insert than the standard HashTable, but should be more memory efficient and faster to access.
Source files

Definition at line 81 of file StaticHashTable.H.


Member Typedef Documentation

typedef Iterator< T&, StaticHashTable<T, Key, Hash>& > iterator

Definition at line 114 of file StaticHashTable.H.

typedef Iterator< const T&, const StaticHashTable<T, Key, Hash>& > const_iterator

Definition at line 126 of file StaticHashTable.H.

typedef T value_type

Type of values the StaticHashTable contains.

Definition at line 263 of file StaticHashTable.H.

typedef T& reference

Type that can be used for storing into StaticHashTable::value_type.

objects. This type is usually List::value_type&.

Definition at line 269 of file StaticHashTable.H.

typedef const T& const_reference

Type that can be used for storing into constant.

StaticHashTable::value_type objects. This type is usually const StaticHashTable::value_type&.

Definition at line 276 of file StaticHashTable.H.

typedef label size_type

The type that can represent the size of a StaticHashTable.

Definition at line 279 of file StaticHashTable.H.


Constructor & Destructor Documentation

StaticHashTable ( const label  size = 128  )  [inline]

Construct given initial table size.

Definition at line 56 of file StaticHashTable.C.

StaticHashTable ( Istream &  is,
const label  size = 128 
) [inline]

Construct from Istream.

Definition at line 26 of file StaticHashTableIO.C.

References Foam::abort(), Foam::FatalError, and FatalErrorIn.

Here is the call graph for this function:

StaticHashTable ( const StaticHashTable< T, Key, Hash > &  ht  )  [inline]

Construct as copy.

Definition at line 79 of file StaticHashTable.C.

StaticHashTable ( const Xfer< StaticHashTable< T, Key, Hash > > &  ht  )  [inline]

Construct by transferring the parameter contents.

Definition at line 95 of file StaticHashTable.C.

~StaticHashTable (  )  [inline]

Definition at line 113 of file StaticHashTable.C.


Member Function Documentation

Foam::label size (  )  const [inline]

Return number of elements in table.

Definition at line 37 of file StaticHashTableI.H.

bool empty (  )  const [inline]

Return true if the hash table is empty.

Definition at line 44 of file StaticHashTableI.H.

bool found ( const Key &  key  )  const [inline]

Return true if hashed entry is found in table.

Definition at line 120 of file StaticHashTable.C.

Foam::StaticHashTable< T, Key, Hash >::iterator find ( const Key &  key  )  [inline]

Find and return an iterator set at the hashed entry.

If not found iterator = end()

Definition at line 151 of file StaticHashTable.C.

Foam::StaticHashTable< T, Key, Hash >::const_iterator find ( const Key &  key  )  const [inline]

Find and return an const_iterator set at the hashed entry.

If not found iterator = end()

Definition at line 184 of file StaticHashTable.C.

Foam::List< Key > toc (  )  const [inline]

Return the table of contents.

Definition at line 216 of file StaticHashTable.C.

Foam::Ostream & printInfo ( Ostream &  os  )  const [inline]

Print information.

Definition at line 55 of file StaticHashTableIO.C.

bool insert ( const Key &  key,
const T &  newElmt 
) [inline]

Insert a new hashed entry.

Definition at line 52 of file StaticHashTableI.H.

bool set ( const Key &  key,
const T &  newElmt 
) [inline]

Assign a new hashed entry, overwriting existing entries.

Definition at line 63 of file StaticHashTableI.H.

bool erase ( const iterator &  it  )  [inline]

Erase an hashed entry specified by given iterator.

Definition at line 290 of file StaticHashTable.C.

bool erase ( const Key &  key  )  [inline]

Erase an hashed entry specified by given key if in table.

Definition at line 361 of file StaticHashTable.C.

void resize ( const label  newSize  )  [inline]

Resize the hash table for efficiency.

Definition at line 399 of file StaticHashTable.C.

Referenced by StaticHashTable< T, Key, Hash >::transfer().

Here is the caller graph for this function:

Foam::label erase ( const StaticHashTable< T, Key, Hash > &  rhs  )  [inline]

Remove entries in the given hash table from this hash table.

Return the number of elements removed

Definition at line 378 of file StaticHashTable.C.

void clear (  )  [inline]

Clear all entries from table.

Definition at line 442 of file StaticHashTable.C.

Referenced by StaticHashTable< T, Key, Hash >::transfer().

Here is the caller graph for this function:

void clearStorage (  )  [inline]

Clear the table entries and the table itself.

Equivalent to clear() followed by resize(1)

Definition at line 455 of file StaticHashTable.C.

void transfer ( StaticHashTable< T, Key, Hash > &  ht  )  [inline]

Transfer the contents of the argument table into this table.

and annull the argument table.

Definition at line 465 of file StaticHashTable.C.

References StaticHashTable< T, Key, Hash >::clear(), and StaticHashTable< T, Key, Hash >::resize().

Here is the call graph for this function:

Foam::Xfer< Foam::StaticHashTable< T, Key, Hash > > xfer (  )  [inline]

Transfer contents to the Xfer container.

Definition at line 74 of file StaticHashTableI.H.

T & operator[] ( const Key &  key  )  [inline]

Find and return an hashed entry.

Definition at line 83 of file StaticHashTableI.H.

References Foam::xferMove().

Here is the call graph for this function:

const T & operator[] ( const Key &  key  )  const [inline]

Find and return an hashed entry.

Definition at line 101 of file StaticHashTableI.H.

T & operator() ( const Key &  key  )  [inline]

Find and return an hashed entry, create it null if not present.

Definition at line 122 of file StaticHashTableI.H.

void operator= ( const StaticHashTable< T, Key, Hash > &  rhs  )  [inline]

Assignment.

Definition at line 492 of file StaticHashTable.C.

bool operator== ( const StaticHashTable< T, Key, Hash > &  rhs  )  const [inline]

Equality. Two hash tables are equal if all contents of first are.

also in second and vice versa.

Definition at line 533 of file StaticHashTable.C.

References insert().

Here is the call graph for this function:

bool operator!= ( const StaticHashTable< T, Key, Hash > &  rhs  )  const [inline]

The opposite of the equality operation.

Definition at line 564 of file StaticHashTable.C.

Foam::StaticHashTable< T, Key, Hash >::iterator begin (  )  [inline]

iterator set to the beginning of the StaticHashTable

Definition at line 328 of file StaticHashTableI.H.

const Foam::StaticHashTable< T, Key, Hash >::iterator & end (  )  [inline]

iterator set to beyond the end of the StaticHashTable

Definition at line 352 of file StaticHashTableI.H.

Foam::StaticHashTable< T, Key, Hash >::const_iterator cbegin (  )  const [inline]

const_iterator set to the beginning of the StaticHashTable

Definition at line 360 of file StaticHashTableI.H.

Referenced by StaticHashTable< T, Key, Hash >::end().

Here is the caller graph for this function:

const Foam::StaticHashTable< T, Key, Hash >::const_iterator & cend (  )  const [inline]

const_iterator set to beyond the end of the StaticHashTable

Definition at line 384 of file StaticHashTableI.H.

Foam::StaticHashTable< T, Key, Hash >::const_iterator begin (  )  const [inline]

const_iterator set to the beginning of the StaticHashTable

Definition at line 392 of file StaticHashTableI.H.

const Foam::StaticHashTable< T, Key, Hash >::const_iterator & end (  )  const [inline]

const_iterator set to beyond the end of the StaticHashTable

Definition at line 400 of file StaticHashTableI.H.

References StaticHashTable< T, Key, Hash >::cbegin().

Here is the call graph for this function:


Friends And Related Function Documentation

friend class Iterator< T &,StaticHashTable< T, Key, Hash > & > [friend]

Definition at line 135 of file StaticHashTable.H.

friend class Iterator< const T &,const StaticHashTable< T, Key, Hash > & > [friend]

Definition at line 141 of file StaticHashTable.H.

Istream& operator>> ( Istream &  ,
StaticHashTable< T, Key, Hash > &   
) [friend]

Ostream& operator ( Ostream &  ,
const StaticHashTable< T, Key, Hash > &   
) [friend]


The documentation for this class was generated from the following files:
Copyright © 2000-2009 OpenCFD Ltd