Loading...
Searching...
No Matches
EST_THash< K, V > Class Template Reference

`#include <include/EST_THash.h>`

Inheritance diagram for EST_THash< K, V >:
[legend]
Collaboration diagram for EST_THash< K, V >:
[legend]

## Classes

struct | IPointer_s
struct | IPointer_k_s

## Public Member Functions

| EST_THash (int size, unsigned int(*hash_function)(const K &key, unsigned int size)=NULL)
| EST_THash (const EST_THash< K, V > &from)
| Create a copy.
| ~EST_THash (void)
| Destroy the table.
void | clear (void)
| Empty the table.
unsigned int | num_entries (void) const
| Return the total number of entries in the table.
int | present (const K &key) const
| Does the key have an entry?
V & | val (const K &key, int &found) const
V & | val (const K &key) const
| Return the value associated with the key.
const K & | key (const V &val, int &found) const
const K & | key (const V &val) const
void | copy (const EST_THash< K, V > &from)
| Copy all entries.
void | map (void(*func)(K &, V &))
| Apply <parameter>func</parameter> to each entry in the table.
int | add_item (const K &key, const V &value, int no_search=0)
| Add an entry to the table.
int | remove_item (const K &rkey, int quiet=0)
| Remove an entry from the table.
EST_THash< K, V > & | operator= (const EST_THash< K, V > &from)
| Assignment is a copy operation.
void | dump (ostream &stream, int all=0)
| Print the table to <parameter>stream</parameter> in a human readable format.

## Pair Iteration

This iterator steps through the table returning key-value pairs.
typedef struct IPointer_s | IPointer
typedef EST_Hash_Pair< K, V > | Entry
| An entry returned by the iterator is a key value pair.
typedef EST_TStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > > | Entries
| Give the iterator a sensible name.
typedef EST_TRwStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > > | RwEntries
class | EST_TStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
| The iterator must be a friend to access this private interface.
class | EST_TRwStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
class | EST_TIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
class | EST_TRwIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >
void | skip_blank (IPointer &ip) const
| Shift to point at something.
void | point_to_first (IPointer &ip) const
| Go to start of the table.
void | move_pointer_forwards (IPointer &ip) const
| Move pointer forwards, at the end of the bucket, move down.
bool | points_to_something (const IPointer &ip) const
| We are at the end if the pointer ever becomes NULL.
EST_Hash_Pair< K, V > & | points_at (const IPointer &ip)
| Return the contents of this entry.

## Key Iteration

This iterator steps through the table returning just keys.
typedef struct IPointer_k_s | IPointer_k
typedef K | KeyEntry
| An entry returned by this iterator is just a key.
typedef EST_TIterator< EST_THash< K, V >, IPointer_k, K > | KeyEntries
| Give the iterator a sensible name.
typedef EST_TRwIterator< EST_THash< K, V >, IPointer_k, K > | KeyRwEntries
class | EST_TIterator< EST_THash< K, V >, IPointer_k, K >
| The iterator must be a friend to access this private interface.
class | EST_TRwIterator< EST_THash< K, V >, IPointer_k, K >
void | skip_blank (IPointer_k &ip) const
| Shift to point at something.
void | point_to_first (IPointer_k &ip) const
| Go to start of the table.
void | move_pointer_forwards (IPointer_k &ip) const
| Move pointer forwards, at the end of the bucket, move down.
bool | points_to_something (const IPointer_k &ip) const
| We are at the end if the pointer ever becomes NULL.
K & | points_at (const IPointer_k &ip)
| Return the key of this entry.

## Additional Inherited Members

Static Protected Member Functions inherited from EST_HashFunctions
static unsigned int | DefaultHash (const void *data, size_t size, unsigned int n)
| A generally useful hash function.
static unsigned int | StringHash (const EST_String &key, unsigned int size)
| A hash function for strings.

## Detailed Description

template<class K, class V>
class EST_THash< K, V >

An open hash table. The number of buckets should be set to allow enough space that there are relatively few entries per bucket on average.

Definition at line 96 of file EST_THash.h.

## Member Typedef Documentation

## IPointer

template<class K, class V>

typedef struct IPointer_s EST_THash< K, V >::IPointer

protected

Definition at line 179 of file EST_THash.h.

## Entry

template<class K, class V>

typedef EST_Hash_Pair<K, V> EST_THash< K, V >::Entry

An entry returned by the iterator is a key value pair.

Definition at line 214 of file EST_THash.h.

## Entries

template<class K, class V>

typedef EST_TStructIterator< EST_THash<K, V>, IPointer, EST_Hash_Pair<K, V> > EST_THash< K, V >::Entries

Give the iterator a sensible name.

Definition at line 217 of file EST_THash.h.

## RwEntries

template<class K, class V>

typedef EST_TRwStructIterator< EST_THash<K, V>, IPointer, EST_Hash_Pair<K, V> > EST_THash< K, V >::RwEntries

Definition at line 218 of file EST_THash.h.

## IPointer_k

template<class K, class V>

typedef struct IPointer_k_s EST_THash< K, V >::IPointer_k

protected

Definition at line 232 of file EST_THash.h.

## KeyEntry

template<class K, class V>

typedef K EST_THash< K, V >::KeyEntry

An entry returned by this iterator is just a key.

Definition at line 265 of file EST_THash.h.

## KeyEntries

template<class K, class V>

typedef EST_TIterator< EST_THash<K, V>, IPointer_k, K > EST_THash< K, V >::KeyEntries

Give the iterator a sensible name.

Definition at line 268 of file EST_THash.h.

## KeyRwEntries

template<class K, class V>

typedef EST_TRwIterator< EST_THash<K, V>, IPointer_k, K > EST_THash< K, V >::KeyRwEntries

Definition at line 269 of file EST_THash.h.

## Constructor & Destructor Documentation

## EST_THash() [1/2]

template<class K, class V>

EST_THash< K, V >::EST_THash | ( | int | size,
|  | unsigned int(* | hash_function )(const K &key, unsigned int size) = NULL )

Create a table with the given number of buckets. Optionally setting a custom hash function.

Definition at line 45 of file EST_THash.cc.

## EST_THash() [2/2]

template<class K, class V>

EST_THash< K, V >::EST_THash | ( | const EST_THash< K, V > & | from | ) |

Create a copy.

Definition at line 59 of file EST_THash.cc.

## ~EST_THash()

template<class K, class V>

EST_THash< K, V >::~EST_THash | ( | void |  | ) |

Destroy the table.

Definition at line 85 of file EST_THash.cc.

## Member Function Documentation

## clear()

template<class K, class V>

void EST_THash< K, V >::clear | ( | void |  | ) |

Empty the table.

Definition at line 66 of file EST_THash.cc.

## num_entries()

template<class K, class V>

unsigned int EST_THash< K, V >::num_entries | ( | void |  | ) | const

inline

Return the total number of entries in the table.

Definition at line 132 of file EST_THash.h.

## present()

template<class K, class V>

int EST_THash< K, V >::present | ( | const K & | key | ) | const

Does the key have an entry?

Definition at line 96 of file EST_THash.cc.

## val() [1/2]

template<class K, class V>

V & EST_THash< K, V >::val | ( | const K & | key,
|  | int & | found ) const

Return the value associated with the key. <parameter>found</parameter> is set to whether such an entry was found.

Definition at line 114 of file EST_THash.cc.

## val() [2/2]

template<class K, class V>

V & EST_THash< K, V >::val | ( | const K & | key | ) | const

inline

Return the value associated with the key.

Definition at line 144 of file EST_THash.h.

## key() [1/2]

template<class K, class V>

const K & EST_THash< K, V >::key | ( | const V & | val,
|  | int & | found ) const

Definition at line 136 of file EST_THash.cc.

## key() [2/2]

template<class K, class V>

const K & EST_THash< K, V >::key | ( | const V & | val | ) | const

inline

Definition at line 147 of file EST_THash.h.

## copy()

template<class K, class V>

void EST_THash< K, V >::copy | ( | const EST_THash< K, V > & | from | ) |

Copy all entries.

Definition at line 242 of file EST_THash.cc.

## map()

template<class K, class V>

void EST_THash< K, V >::map | ( | void(* | func )(K &, V &) | ) |

Apply <parameter>func</parameter> to each entry in the table.

Definition at line 154 of file EST_THash.cc.

## add_item()

template<class K, class V>

int EST_THash< K, V >::add_item | ( | const K & | key,
|  | const V & | value,
|  | int | no_search = 0 )

Add an entry to the table.

Definition at line 167 of file EST_THash.cc.

## remove_item()

template<class K, class V>

int EST_THash< K, V >::remove_item | ( | const K & | rkey,
|  | int | quiet = 0 )

Remove an entry from the table.

Definition at line 195 of file EST_THash.cc.

## operator=()

template<class K, class V>

EST_THash< K, V > & EST_THash< K, V >::operator= | ( | const EST_THash< K, V > & | from | ) |

Assignment is a copy operation.

Definition at line 221 of file EST_THash.cc.

## dump()

template<class K, class V>

void EST_THash< K, V >::dump | ( | ostream & | stream,
|  | int | all = 0 )

Print the table to <parameter>stream</parameter> in a human readable format.

Definition at line 228 of file EST_THash.cc.

## skip_blank() [1/2]

template<class K, class V>

void EST_THash< K, V >::skip_blank | ( | IPointer & | ip | ) | const

inline protected

Shift to point at something.

Definition at line 182 of file EST_THash.h.

## point_to_first() [1/2]

template<class K, class V>

void EST_THash< K, V >::point_to_first | ( | IPointer & | ip | ) | const

inline protected

Go to start of the table.

Definition at line 189 of file EST_THash.h.

## move_pointer_forwards() [1/2]

template<class K, class V>

void EST_THash< K, V >::move_pointer_forwards | ( | IPointer & | ip | ) | const

inline protected

Move pointer forwards, at the end of the bucket, move down.

Definition at line 194 of file EST_THash.h.

## points_to_something() [1/2]

template<class K, class V>

bool EST_THash< K, V >::points_to_something | ( | const IPointer & | ip | ) | const

inline protected

We are at the end if the pointer ever becomes NULL.

Definition at line 201 of file EST_THash.h.

## points_at() [1/2]

template<class K, class V>

EST_Hash_Pair< K, V > & EST_THash< K, V >::points_at | ( | const IPointer & | ip | ) |

inline protected

Return the contents of this entry.

Definition at line 204 of file EST_THash.h.

## skip_blank() [2/2]

template<class K, class V>

void EST_THash< K, V >::skip_blank | ( | IPointer_k & | ip | ) | const

inline protected

Shift to point at something.

Definition at line 235 of file EST_THash.h.

## point_to_first() [2/2]

template<class K, class V>

void EST_THash< K, V >::point_to_first | ( | IPointer_k & | ip | ) | const

inline protected

Go to start of the table.

Definition at line 242 of file EST_THash.h.

## move_pointer_forwards() [2/2]

template<class K, class V>

void EST_THash< K, V >::move_pointer_forwards | ( | IPointer_k & | ip | ) | const

inline protected

Move pointer forwards, at the end of the bucket, move down.

Definition at line 247 of file EST_THash.h.

## points_to_something() [2/2]

template<class K, class V>

bool EST_THash< K, V >::points_to_something | ( | const IPointer_k & | ip | ) | const

inline protected

We are at the end if the pointer ever becomes NULL.

Definition at line 254 of file EST_THash.h.

## points_at() [2/2]

template<class K, class V>

K & EST_THash< K, V >::points_at | ( | const IPointer_k & | ip | ) |

inline protected

Return the key of this entry.

Definition at line 257 of file EST_THash.h.

## Friends And Related Symbol Documentation

## EST_TStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >

template<class K, class V>

friend class EST_TStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >

friend

The iterator must be a friend to access this private interface.

Definition at line 204 of file EST_THash.h.

## EST_TRwStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >

template<class K, class V>

friend class EST_TRwStructIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >

friend

Definition at line 204 of file EST_THash.h.

## EST_TIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >

template<class K, class V>

friend class EST_TIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >

friend

Definition at line 204 of file EST_THash.h.

## EST_TRwIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >

template<class K, class V>

friend class EST_TRwIterator< EST_THash< K, V >, IPointer, EST_Hash_Pair< K, V > >

friend

Definition at line 204 of file EST_THash.h.

## EST_TIterator< EST_THash< K, V >, IPointer_k, K >

template<class K, class V>

friend class EST_TIterator< EST_THash< K, V >, IPointer_k, K >

friend

The iterator must be a friend to access this private interface.

Definition at line 257 of file EST_THash.h.

## EST_TRwIterator< EST_THash< K, V >, IPointer_k, K >

template<class K, class V>

friend class EST_TRwIterator< EST_THash< K, V >, IPointer_k, K >

friend

Definition at line 257 of file EST_THash.h.

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

- include/EST_THash.h
- base_class/EST_THash.cc