w_hash_t< T, LOCK, K > Class Template Reference

Inherits w_base_t.

Inheritance diagram for w_hash_t< T, LOCK, K >:

Inheritance graph
[legend]
Collaboration diagram for w_hash_t< T, LOCK, K >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T, class LOCK, class K>
class w_hash_t< T, LOCK, K >

Templated hash table. Not particularly sophisticated.

The hash function used here is :

Thus, to make this work, you need to define a (static, global, or inlined) function

 w_base_t::uint4_t w_hash(const K &key)

Note that since the hash function uses the _mask to collect the lower bits of the result of w_hash, the w_hash(key) function should be sensitive to the way hash-table uses of the w_hash function, and the hash tables should be aware of the likely bit distribution of the result of w_hash(key).

Bug:
(GNATS 114, non-critical performance issue) improve these hash funcs. This is used in: histograms, dirty page table for restart.

Definition at line 122 of file w_hash.h.

Public Member Functions

NORET w_hash_t (uint4_t sz, uint4_t key_offset, uint4_t link_offset, const LOCK *lock)
 Construct hash table.
w_hash_tpush (T *t)
 Insert an element in the table at the front of its bucket.
w_hash_tappend (T *t)
 Insert an element in the table at the tail of its bucket.
T * lookup (const K &k) const
 Find an element in the table.
bool member (T const *t) const
 True if element is in the table.
T * remove (const K &k)
 Remove the (single) element with the given key.
void remove (T *t)
 Remove the given element that is in the table.
uint4_t num_members () const
 Total number of elements in the table.

Friends

ostream &const w_hash_t< T,
LOCK, K > & 
obj
ostream & operator<< BIND_FRIEND_OPERATOR_PART_2B (T, LOCK, K)(ostream &o
 Standard ostream operator, despite the macro here (in w_workaround.h).


Constructor & Destructor Documentation

template<class T, class LOCK, class K>
NORET w_hash_t< T, LOCK, K >::w_hash_t ( uint4_t  sz,
uint4_t  key_offset,
uint4_t  link_offset,
const LOCK *  lock 
)

Construct hash table.

Parameters:
[in] sz Number of bits in result values.
[in] key_offset Offset in object of type T where key K is found
[in] link_offset Offset in object of type T where w_link_t is found This w_link_t is used to hold the object in a hash table bucket
[in] lock Pointer to a lock used to protect the table.
The size determines a mask used to restrict the resulting hash values to a desired size.

The lock passed in is not used. There is no enforcement of locking these structures. The template contains the lock type so that it is relatively easy to tell what structures are unprotected by perusing the code.

See W_HASH_ARG(class,key,link)


The documentation for this class was generated from the following file:
Generated on Wed Jul 7 17:22:43 2010 for Shore Storage Manager by  doxygen 1.4.7