Classes | Public Member Functions

nanojit::HashMap< K, T, H > Class Template Reference

Bucket hashtable with a fixed # of buckets (never rehash) Intended for use when a reasonable # of buckets can be estimated ahead of time. More...

#include <Containers.h>

Collaboration diagram for nanojit::HashMap< K, T, H >:

List of all members.

Classes

class  Iter
 Iter is an iterator for HashMap, intended to be instantiated on the stack. More...
class  Node

Public Member Functions

 HashMap (Allocator &a, size_t nbuckets=16)
void clear ()
 clear all buckets.
void put (const K &k, const T &v)
 add (k,v) to the map.
get (const K &k)
 return v for element k, or T(0) if k is not present
bool containsKey (const K &k)
 returns true if k is in the map.
void remove (const K &k)
 remove k from the map, if it is present.
bool isEmpty ()
 return true if the hashmap has no elements

Detailed Description

template<class K, class T, class H = DefaultHash<K>>
class nanojit::HashMap< K, T, H >

Bucket hashtable with a fixed # of buckets (never rehash) Intended for use when a reasonable # of buckets can be estimated ahead of time.


Constructor & Destructor Documentation

template<class K, class T, class H = DefaultHash<K>>
nanojit::HashMap< K, T, H >::HashMap ( Allocator a,
size_t  nbuckets = 16 
) [inline]

Member Function Documentation

template<class K, class T, class H = DefaultHash<K>>
void nanojit::HashMap< K, T, H >::clear (  )  [inline]

clear all buckets.

Since we allocate all memory from Allocator, nothing needs to be freed.

template<class K, class T, class H = DefaultHash<K>>
bool nanojit::HashMap< K, T, H >::containsKey ( const K &  k  )  [inline]

returns true if k is in the map.

template<class K, class T, class H = DefaultHash<K>>
T nanojit::HashMap< K, T, H >::get ( const K &  k  )  [inline]

return v for element k, or T(0) if k is not present

template<class K, class T, class H = DefaultHash<K>>
bool nanojit::HashMap< K, T, H >::isEmpty (  )  [inline]

return true if the hashmap has no elements

template<class K, class T, class H = DefaultHash<K>>
void nanojit::HashMap< K, T, H >::put ( const K &  k,
const T &  v 
) [inline]

add (k,v) to the map.

If k is already in the map, replace the value

template<class K, class T, class H = DefaultHash<K>>
void nanojit::HashMap< K, T, H >::remove ( const K &  k  )  [inline]

remove k from the map, if it is present.

if not, remove() silently returns


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