Panda3D
|
This template class implements an unordered map of keys to data, implemented as a hashtable. More...
#include "simpleHashMap.h"
Classes | |
class | TableEntry |
Public Member Functions | |
SimpleHashMap (const Compare &comp=Compare()) | |
void | clear () |
Completely empties the table. | |
int | find (const Key &key) const |
Searches for the indicated key in the table. | |
const Value & | get_data (int n) const |
Returns the data in the nth slot of the table. | |
const Key & | get_key (int n) const |
Returns the key in the nth slot of the table. | |
int | get_num_entries () const |
Returns the number of active entries in the table. | |
int | get_size () const |
Returns the total number of slots in the table. | |
bool | has_element (int n) const |
Returns true if there is an element stored in the nth slot, false otherwise. | |
bool | is_empty () const |
Returns true if the table is empty; i.e. | |
Value & | modify_data (int n) |
Returns a modifiable reference to the data in the nth slot of the table. | |
Value & | operator[] (const Key &key) |
Returns a modifiable reference to the data associated with the indicated key, or creates a new data entry and returns its reference. | |
void | output (ostream &out) const |
bool | remove (const Key &key) |
Removes the indicated key and its associated data from the table. | |
void | remove_element (int n) |
Removes the nth slot from the table. | |
void | set_data (int n, const Value &data) |
Changes the data for the nth slot of the table. | |
int | store (const Key &key, const Value &data) |
Records the indicated key/data pair in the map. | |
void | swap (SimpleHashMap &other) |
Quickly exchanges the contents of this map and the other map. | |
bool | validate () const |
Returns true if the internal table appears to be consistent, false if there are some internal errors. | |
void | write (ostream &out) const |
This template class implements an unordered map of keys to data, implemented as a hashtable.
It is similar to STL's hash_map, but (a) it has a simpler interface (we don't mess around with iterators), (b) it wants an additional method on the Compare object, Compare::is_equal(a, b), and (c) it doesn't depend on the system STL providing hash_map.
Definition at line 33 of file simpleHashMap.h.
void SimpleHashMap< Key, Value, Compare >::clear | ( | ) |
Completely empties the table.
Definition at line 212 of file simpleHashMap.I.
References TypeHandle::none().
Referenced by RenderState::clear_cache(), and TransformState::clear_cache().
int SimpleHashMap< Key, Value, Compare >::find | ( | const Key & | key | ) | const |
Searches for the indicated key in the table.
Returns its index number if it is found, or -1 if it is not present in the table.
Definition at line 78 of file simpleHashMap.I.
Referenced by TransformState::validate_composition_cache().
const Value & SimpleHashMap< Key, Value, Compare >::get_data | ( | int | n | ) | const [inline] |
Returns the data in the nth slot of the table.
It is an error to call this if there is nothing stored in the nth slot (use has_element() to check this first). n should be in the range 0 <= n < get_size().
Definition at line 300 of file simpleHashMap.I.
Referenced by RenderState::clear_cache(), TransformState::clear_cache(), RenderState::get_composition_cache_result(), TransformState::get_composition_cache_result(), RenderState::get_invert_composition_cache_result(), TransformState::get_invert_composition_cache_result(), RenderState::get_num_unused_states(), and TransformState::get_num_unused_states().
const Key & SimpleHashMap< Key, Value, Compare >::get_key | ( | int | n | ) | const [inline] |
Returns the key in the nth slot of the table.
It is an error to call this if there is nothing stored in the nth slot (use has_element() to check this first). n should be in the range 0 <= n < get_size().
Definition at line 283 of file simpleHashMap.I.
Referenced by RenderState::clear_cache(), TransformState::clear_cache(), RenderState::clear_munger_cache(), RenderAttrib::garbage_collect(), RenderState::garbage_collect(), TransformState::garbage_collect(), RenderState::get_composition_cache_source(), TransformState::get_composition_cache_source(), RenderState::get_invert_composition_cache_source(), TransformState::get_invert_composition_cache_source(), RenderState::get_num_unused_states(), TransformState::get_num_unused_states(), RenderAttrib::list_attribs(), RenderState::list_cycles(), TransformState::list_cycles(), RenderState::list_states(), TransformState::list_states(), RenderAttrib::validate_attribs(), TransformState::validate_composition_cache(), RenderState::validate_states(), and TransformState::validate_states().
int SimpleHashMap< Key, Value, Compare >::get_num_entries | ( | ) | const [inline] |
Returns the number of active entries in the table.
This is not necessarily related to the number of slots in the table as reported by get_size(). Use get_size() to iterate through all of the slots, not get_num_entries().
Definition at line 401 of file simpleHashMap.I.
Referenced by RenderState::clear_cache(), TransformState::clear_cache(), RenderAttrib::garbage_collect(), RenderState::garbage_collect(), TransformState::garbage_collect(), RenderState::get_composition_cache_num_entries(), TransformState::get_composition_cache_num_entries(), RenderState::get_invert_composition_cache_num_entries(), TransformState::get_invert_composition_cache_num_entries(), RenderAttrib::get_num_attribs(), RenderState::get_num_states(), TransformState::get_num_states(), RenderAttrib::list_attribs(), RenderState::list_states(), and TransformState::list_states().
int SimpleHashMap< Key, Value, Compare >::get_size | ( | ) | const [inline] |
Returns the total number of slots in the table.
Definition at line 252 of file simpleHashMap.I.
Referenced by RenderState::clear_cache(), TransformState::clear_cache(), RenderState::clear_munger_cache(), RenderAttrib::garbage_collect(), RenderState::garbage_collect(), TransformState::garbage_collect(), RenderState::get_composition_cache_size(), TransformState::get_composition_cache_size(), RenderState::get_invert_composition_cache_size(), TransformState::get_invert_composition_cache_size(), RenderState::get_num_unused_states(), TransformState::get_num_unused_states(), RenderAttrib::list_attribs(), RenderState::list_cycles(), TransformState::list_cycles(), RenderState::list_states(), TransformState::list_states(), RenderAttrib::validate_attribs(), TransformState::validate_composition_cache(), RenderState::validate_states(), and TransformState::validate_states().
bool SimpleHashMap< Key, Value, Compare >::has_element | ( | int | n | ) | const [inline] |
Returns true if there is an element stored in the nth slot, false otherwise.
n should be in the range 0 <= n < get_size().
Definition at line 266 of file simpleHashMap.I.
Referenced by RenderState::clear_cache(), TransformState::clear_cache(), RenderState::clear_munger_cache(), RenderAttrib::garbage_collect(), RenderState::garbage_collect(), TransformState::garbage_collect(), RenderState::get_composition_cache_result(), TransformState::get_composition_cache_result(), RenderState::get_composition_cache_source(), TransformState::get_composition_cache_source(), RenderState::get_invert_composition_cache_result(), TransformState::get_invert_composition_cache_result(), RenderState::get_invert_composition_cache_source(), TransformState::get_invert_composition_cache_source(), RenderState::get_num_unused_states(), TransformState::get_num_unused_states(), RenderAttrib::list_attribs(), RenderState::list_cycles(), TransformState::list_cycles(), RenderState::list_states(), TransformState::list_states(), RenderAttrib::validate_attribs(), and TransformState::validate_composition_cache().
bool SimpleHashMap< Key, Value, Compare >::is_empty | ( | ) | const [inline] |
Returns true if the table is empty; i.e.
get_num_entries() == 0.
Definition at line 413 of file simpleHashMap.I.
Referenced by RenderAttrib::validate_attribs(), RenderState::validate_states(), TransformState::validate_states(), RenderState::~RenderState(), and TransformState::~TransformState().
Value & SimpleHashMap< Key, Value, Compare >::modify_data | ( | int | n | ) | [inline] |
Returns a modifiable reference to the data in the nth slot of the table.
It is an error to call this if there is nothing stored in the nth slot (use has_element() to check this first). n should be in the range 0 <= n < get_size().
Definition at line 318 of file simpleHashMap.I.
Value & SimpleHashMap< Key, Value, Compare >::operator[] | ( | const Key & | key | ) | [inline] |
Returns a modifiable reference to the data associated with the indicated key, or creates a new data entry and returns its reference.
Definition at line 237 of file simpleHashMap.I.
bool SimpleHashMap< Key, Value, Compare >::remove | ( | const Key & | key | ) | [inline] |
Removes the indicated key and its associated data from the table.
Returns true if the key was removed, false if it was not present.
Definition at line 196 of file simpleHashMap.I.
void SimpleHashMap< Key, Value, Compare >::remove_element | ( | int | n | ) |
Removes the nth slot from the table.
It is an error to call this if there is nothing stored in the nth slot (use has_element() to check this first). n should be in the range 0 <= n < get_size().
Definition at line 352 of file simpleHashMap.I.
void SimpleHashMap< Key, Value, Compare >::set_data | ( | int | n, |
const Value & | data | ||
) | [inline] |
Changes the data for the nth slot of the table.
It is an error to call this if there is nothing stored in the nth slot (use has_element() to check this first). n should be in the range 0 <= n < get_size().
Definition at line 335 of file simpleHashMap.I.
int SimpleHashMap< Key, Value, Compare >::store | ( | const Key & | key, |
const Value & | data | ||
) |
Records the indicated key/data pair in the map.
If the key was already present, silently replaces it. Returns the index at which it was stored.
Definition at line 118 of file simpleHashMap.I.
void SimpleHashMap< Key, Value, Compare >::swap | ( | SimpleHashMap< Key, Value, Compare > & | other | ) | [inline] |
Quickly exchanges the contents of this map and the other map.
Definition at line 51 of file simpleHashMap.I.
bool SimpleHashMap< Key, Value, Compare >::validate | ( | ) | const |
Returns true if the internal table appears to be consistent, false if there are some internal errors.
Definition at line 463 of file simpleHashMap.I.
Referenced by RenderAttrib::garbage_collect(), RenderState::garbage_collect(), TransformState::garbage_collect(), RenderAttrib::validate_attribs(), RenderState::validate_states(), and TransformState::validate_states().