Tpetra Matrix/Vector Services Version of the Day
Public Member Functions
Tpetra::Details::FixedHashTable< KeyType, ValueType > Class Template Reference

#include <Tpetra_Details_FixedHashTable_decl.hpp>

Inheritance diagram for Tpetra::Details::FixedHashTable< KeyType, ValueType >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 FixedHashTable (const ArrayView< const KeyType > &keys)
 Constructor for arbitrary keys and contiguous values starting with zero.
 FixedHashTable (const ArrayView< const KeyType > &keys, const ValueType startingValue)
 Constructor for arbitrary keys and contiguous values starting with startingValue.
 FixedHashTable (const ArrayView< const KeyType > &keys, const ArrayView< const ValueType > &vals)
 Constructor for arbitrary keys and arbitrary values.
 FixedHashTable (const FixedHashTable &obj)
 Copy constructor: Make a shallow copy of the data.
ValueType get (const KeyType key) const
 Get the value corresponding to the given key.
bool hasDuplicateKeys () const
 Whether the table noticed any duplicate keys on construction.
std::string description () const
 Implementation of Teuchos::Describable.
void describe (Teuchos::FancyOStream &out, const Teuchos::EVerbosityLevel verbLevel=Teuchos::Describable::verbLevel_default) const
 Print this object with the given verbosity to the output stream.

Detailed Description

template<typename KeyType, typename ValueType>
class Tpetra::Details::FixedHashTable< KeyType, ValueType >

Template Parameters:
KeyTypeThe type of the hash table's keys. This must be a built-in signed or unsinged integer type.
ValueTypeThe type of the hash table's values. This must be a built-in signed or unsigned integer type.

This class implements a hash table from signed integer keys to signed integer values, where all the (key,value) pairs must be added at once, and may not be changed or removed after being added. Keys and values may have different types. Tpetra::Map may use this to implement global-to-local index lookup.

The hash table uses a "compressed sparse row" storage strategy. The hash function maps a key to its "row" in the table, and then we search within that row to find the corresponding value. In each row, we store a key and its value adjacent to each other. This strategy puts (key,value) pairs in a single contiguous array, rather than in separately allocated buckets (as in a conventional dynamically allocated hash table). This saves initialization time, as long as the hash function takes less than half the time of a system call to allocate memory. This is because there are only $O(1)$ memory allocation calls, rather than one for each (key,value) pair or hash bucket. The compressed sparse row strategy may also improve locality for hash table lookups.

Definition at line 79 of file Tpetra_Details_FixedHashTable_decl.hpp.


Constructor & Destructor Documentation

template<typename KeyType , typename ValueType >
Tpetra::Details::FixedHashTable< KeyType, ValueType >::FixedHashTable ( const ArrayView< const KeyType > &  keys)

Constructor for arbitrary keys and contiguous values starting with zero.

Add (keys[i], i) to the table, for i = 0, 1, ..., keys.size().

Definition at line 146 of file Tpetra_Details_FixedHashTable_def.hpp.

template<typename KeyType , typename ValueType >
Tpetra::Details::FixedHashTable< KeyType, ValueType >::FixedHashTable ( const ArrayView< const KeyType > &  keys,
const ValueType  startingValue 
)

Constructor for arbitrary keys and contiguous values starting with startingValue.

Add (keys[i], startingValue + i) to the table, for i = 0, 1, ..., keys.size(). This version is useful if Map wants to exclude an initial sequence of contiguous GIDs from the table, and start with a given LID.

Definition at line 157 of file Tpetra_Details_FixedHashTable_def.hpp.

template<typename KeyType , typename ValueType >
Tpetra::Details::FixedHashTable< KeyType, ValueType >::FixedHashTable ( const ArrayView< const KeyType > &  keys,
const ArrayView< const ValueType > &  vals 
)

Constructor for arbitrary keys and arbitrary values.

Add (keys[i], vals[i]) to the table, for i = 0, 1, ..., keys.size(). This version is useful for applications other than Map's GID-to-LID lookup table.

Definition at line 169 of file Tpetra_Details_FixedHashTable_def.hpp.

template<typename KeyType , typename ValueType >
Tpetra::Details::FixedHashTable< KeyType, ValueType >::FixedHashTable ( const FixedHashTable< KeyType, ValueType > &  obj)

Copy constructor: Make a shallow copy of the data.

Definition at line 389 of file Tpetra_Details_FixedHashTable_def.hpp.


Member Function Documentation

template<typename KeyType , typename ValueType >
ValueType Tpetra::Details::FixedHashTable< KeyType, ValueType >::get ( const KeyType  key) const

Get the value corresponding to the given key.

Definition at line 401 of file Tpetra_Details_FixedHashTable_def.hpp.

template<typename KeyType , typename ValueType >
bool Tpetra::Details::FixedHashTable< KeyType, ValueType >::hasDuplicateKeys ( ) const [inline]

Whether the table noticed any duplicate keys on construction.

Definition at line 113 of file Tpetra_Details_FixedHashTable_decl.hpp.

template<typename KeyType , typename ValueType >
std::string Tpetra::Details::FixedHashTable< KeyType, ValueType >::description ( ) const [virtual]

Implementation of Teuchos::Describable.

Return a simple one-line description of this object.

Reimplemented from Teuchos::Describable.

Definition at line 426 of file Tpetra_Details_FixedHashTable_def.hpp.

template<typename KeyType , typename ValueType >
void Tpetra::Details::FixedHashTable< KeyType, ValueType >::describe ( Teuchos::FancyOStream out,
const Teuchos::EVerbosityLevel  verbLevel = Teuchos::Describable::verbLevel_default 
) const [virtual]

Print this object with the given verbosity to the output stream.

Reimplemented from Teuchos::Describable.

Definition at line 439 of file Tpetra_Details_FixedHashTable_def.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines