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 >: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. | |
| T | 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 | |
Bucket hashtable with a fixed # of buckets (never rehash) Intended for use when a reasonable # of buckets can be estimated ahead of time.
Note that operator== is used to compare keys.
| nanojit::HashMap< K, T, H >::HashMap | ( | Allocator & | a, | |
| size_t | nbuckets = 16 | |||
| ) | [inline] |
| void nanojit::HashMap< K, T, H >::clear | ( | ) | [inline] |
clear all buckets.
Since we allocate all memory from Allocator, nothing needs to be freed.
| bool nanojit::HashMap< K, T, H >::containsKey | ( | const K & | k | ) | [inline] |
returns true if k is in the map.
| T nanojit::HashMap< K, T, H >::get | ( | const K & | k | ) | [inline] |
return v for element k, or T(0) if k is not present
| bool nanojit::HashMap< K, T, H >::isEmpty | ( | ) | [inline] |
return true if the hashmap has no elements
| 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
| 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
1.7.1