Teuchos Package Browser (Single Doxygen Collection)  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | Related Functions | List of all members
Teuchos::Hashtable< Key, Value > Class Template Reference

Templated hashtable class. More...

#include <Teuchos_Hashtable.hpp>

Public Member Functions

 Hashtable (int capacity=101, double rehashDensity=0.8)
 Create an empty Hashtable. More...
 
bool containsKey (const Key &key) const
 Check for the presence of a key. More...
 
const Value & get (const Key &key) const
 Get the value indexed by key. More...
 
void put (const Key &key, const Value &value)
 Put a new (key, value) pair in the table. More...
 
void remove (const Key &key)
 Remove from the table the element given by key. More...
 
int size () const
 Get the number of elements in the table. More...
 
void arrayify (Array< Key > &keys, Array< Value > &values) const
 Get lists of keys and values in Array form. More...
 
double avgDegeneracy () const
 Return the average degeneracy (average number of entries per hash code). More...
 
double density () const
 Return the density of the hashtable (num entries / capacity) More...
 
void setRehashDensity (double rehashDensity)
 Set the density at which to do a rehash. More...
 
std::string toString () const
 Write to a std::string. More...
 

Private Member Functions

void rehash ()
 
int nextPrime (int newCap) const
 
void accumulateAvgFill (int n) const
 

Private Attributes

Array< Array< HashPair< Key,
Value > > > 
data_
 
int count_
 
int capacity_
 
Value mostRecentValue_
 
Key mostRecentKey_
 
size_t nHits_
 
double avgDegeneracy_
 
double rehashDensity_
 

Related Functions

(Note that these are not member functions.)

template<class Key , class Value >
std::ostream & operator<< (std::ostream &os, const Hashtable< Key, Value > &h)
 Write Hashtable to a stream. More...
 

Detailed Description

template<class Key, class Value>
class Teuchos::Hashtable< Key, Value >

Templated hashtable class.

Author
Kevin Long

Definition at line 48 of file Teuchos_Hashtable.hpp.

Constructor & Destructor Documentation

template<class Key , class Value >
Teuchos::Hashtable< Key, Value >::Hashtable ( int  capacity = 101,
double  rehashDensity = 0.8 
)
inline

Create an empty Hashtable.

Definition at line 113 of file Teuchos_Hashtable.hpp.

Member Function Documentation

template<class Key , class Value >
bool Teuchos::Hashtable< Key, Value >::containsKey ( const Key &  key) const
inline

Check for the presence of a key.

Definition at line 125 of file Teuchos_Hashtable.hpp.

template<class Key , class Value >
const Value & Teuchos::Hashtable< Key, Value >::get ( const Key &  key) const
inline

Get the value indexed by key.

Definition at line 250 of file Teuchos_Hashtable.hpp.

template<class Key , class Value >
void Teuchos::Hashtable< Key, Value >::put ( const Key &  key,
const Value &  value 
)
inline

Put a new (key, value) pair in the table.

Definition at line 144 of file Teuchos_Hashtable.hpp.

template<class Key , class Value >
void Teuchos::Hashtable< Key, Value >::remove ( const Key &  key)
inline

Remove from the table the element given by key.

Definition at line 277 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
int Teuchos::Hashtable< Key, Value >::size ( ) const
inline

Get the number of elements in the table.

Definition at line 68 of file Teuchos_Hashtable.hpp.

template<class Key , class Value >
void Teuchos::Hashtable< Key, Value >::arrayify ( Array< Key > &  keys,
Array< Value > &  values 
) const
inline

Get lists of keys and values in Array form.

Definition at line 196 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
double Teuchos::Hashtable< Key, Value >::avgDegeneracy ( ) const
inline

Return the average degeneracy (average number of entries per hash code).

Definition at line 74 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
double Teuchos::Hashtable< Key, Value >::density ( ) const
inline

Return the density of the hashtable (num entries / capacity)

Definition at line 77 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
void Teuchos::Hashtable< Key, Value >::setRehashDensity ( double  rehashDensity)
inline

Set the density at which to do a rehash.

template<class Key , class Value >
std::string Teuchos::Hashtable< Key, Value >::toString ( ) const
inline

Write to a std::string.

Definition at line 212 of file Teuchos_Hashtable.hpp.

template<class Key , class Value >
void Teuchos::Hashtable< Key, Value >::rehash ( )
inlineprivate

Definition at line 178 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
int Teuchos::Hashtable< Key, Value >::nextPrime ( int  newCap) const
inlineprivate
template<class Key , class Value >
void Teuchos::Hashtable< Key, Value >::accumulateAvgFill ( int  n) const
inlineprivate

Definition at line 302 of file Teuchos_Hashtable.hpp.

Friends And Related Function Documentation

template<class Key , class Value >
std::ostream & operator<< ( std::ostream &  os,
const Hashtable< Key, Value > &  h 
)
related

Write Hashtable to a stream.

Definition at line 309 of file Teuchos_Hashtable.hpp.

Member Data Documentation

template<class Key, class Value>
Array<Array<HashPair<Key, Value> > > Teuchos::Hashtable< Key, Value >::data_
private

Definition at line 92 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
int Teuchos::Hashtable< Key, Value >::count_
private

Definition at line 93 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
int Teuchos::Hashtable< Key, Value >::capacity_
private

Definition at line 94 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
Value Teuchos::Hashtable< Key, Value >::mostRecentValue_
mutableprivate

Definition at line 95 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
Key Teuchos::Hashtable< Key, Value >::mostRecentKey_
mutableprivate

Definition at line 96 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
size_t Teuchos::Hashtable< Key, Value >::nHits_
mutableprivate

Definition at line 98 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
double Teuchos::Hashtable< Key, Value >::avgDegeneracy_
mutableprivate

Definition at line 99 of file Teuchos_Hashtable.hpp.

template<class Key, class Value>
double Teuchos::Hashtable< Key, Value >::rehashDensity_
private

Definition at line 100 of file Teuchos_Hashtable.hpp.


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