hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats > Class Template Reference

#include <FastHash.h>

Inheritance diagram for hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >:

hudson::FastHashMap< Key, Value, hasher, NeedsDelete, collectStats > List of all members.

Public Member Functions

 FastHashBase (size_t size_hint)
 Build a table of size 'size_hint'.
 FastHashBase ()
 Build an empty table.
void reserve (size_t capacity)
 Reserve a table of appropriate size.
 ~FastHashBase ()
 Destructor.
void clear (bool free_table=false)
 Remove all items from the table.
void collectstats (FHS_Stats &s)
pair< iterator, bool > insert (const Key &key)
template<class key_iterator>
void insert (key_iterator begin, const key_iterator &end)
bool erase (const Key &key)
size_t size () const
 Return the number of entries in the table.
size_t capacity () const
const_iterator find (const Key &key) const
iterator find (const Key &key)
iterator end ()
const_iterator end () const

Classes

struct  const_iterator
struct  iterator
struct  link

Detailed Description

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
class hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >

I use a single base class for the hash table. The set sets the value field to void.

TODO: use the boost package to automatically figure out NeedsDelete.


Constructor & Destructor Documentation

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::FastHashBase size_t  size_hint  )  [inline]
 

Build a table of size 'size_hint'.

I round the hint up to the next power of two. There will be no further memory allocation until the size is used up.

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::FastHashBase  )  [inline]
 

Build an empty table.

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::~FastHashBase  )  [inline]
 

Destructor.

If collectStats is true, call collectstats() to dump the current table stats (load, histogram, and so on) into hudson::global_stats.

If NeedsDelete is true, I iterate over the table entries and destroy them all properly. If not (that is, the destructors are trivial), I skip that step and simply deallocate en masse. TODO - that's no longer true: the links themselves need to be deleted.


Member Function Documentation

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
size_t hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::capacity  )  const [inline]
 

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
void hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::clear bool  free_table = false  )  [inline]
 

Remove all items from the table.

Normally, we follow the STL convention of keeping our storage. An optional argument allows overriding that decision.

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
void hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::collectstats FHS_Stats s  )  [inline]
 

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
const_iterator hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::end  )  const [inline]
 

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
iterator hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::end  )  [inline]
 

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
bool hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::erase const Key &  key  )  [inline]
 

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
iterator hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::find const Key &  key  )  [inline]
 

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
const_iterator hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::find const Key &  key  )  const [inline]
 

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
template<class key_iterator>
void hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::insert key_iterator  begin,
const key_iterator &  end
[inline]
 

Insert a range of keys. key_iterator must be a ForwardIterator.

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
pair<iterator,bool> hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::insert const Key &  key  )  [inline]
 

Reimplemented in hudson::FastHashMap< Key, Value, hasher, NeedsDelete, collectStats >.

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
void hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::reserve size_t  capacity  )  [inline]
 

Reserve a table of appropriate size.

The table size is rounded up to the nearest power of two. If the requested size is smaller than is currently in use, nothing happens.

template<typename Key, typename Value, class hasher, bool NeedsDelete, bool collectStats>
size_t hudson::FastHashBase< Key, Value, hasher, NeedsDelete, collectStats >::size  )  const [inline]
 

Return the number of entries in the table.


The documentation for this class was generated from the following file:
Generated on Thu Mar 27 19:04:16 2008 by  doxygen 1.4.6