|
| SmallTable () |
|
Creates an empty hash table using the default MemoryManager. More...
|
|
| SmallTable (const ThisType &h) |
| Uses the default memory manager. More...
|
|
Iterator | begin () const |
|
C++ STL style iterator method. More...
|
|
void | clear () |
|
Removes all elements. More...
|
|
bool | containsKey (const Key &key) const |
|
Returns true if key is in the table. More...
|
|
bool | containsValue (const Value &value) const |
|
Returns true if any key maps to value using operator==. More...
|
|
void | deleteKeys () |
|
Calls delete on all of the keys and then clears the table. More...
|
|
void | deleteValues () |
|
Calls delete on all of the values. More...
|
|
const Iterator | end () const |
|
C++ STL style iterator method. More...
|
|
void | fastClear () |
|
Value & | get (const Key &key) const |
|
Returns the value associated with key. More...
|
|
bool | get (const Key &key, Value &val) const |
|
If the key is present in the table, val is set to the associated value and returns true. More...
|
|
Value & | getCreate (const Key &key) |
| Returns the current value that key maps to, creating it if necessary. More...
|
|
Value & | getCreate (const Key &key, bool &created) |
|
Entry & | getCreateEntry (const Key &key, bool &created) |
| Called by getCreate() and set() More...
|
|
Entry & | getCreateEntry (const Key &key) |
|
const Key * | getKeyPointer (const Key &key) const |
| If a value that is EqualsFunc to member is present, returns a pointer to the version stored in the data structure, otherwise returns nullptr. More...
|
|
Array< Key > | getKeys () const |
|
Returns an array of all of the keys in the table. More...
|
|
void | getKeys (Array< Key > &keyArray) const |
|
Value * | getPointer (const Key &key) const |
| Returns a pointer to the element if it exists, or nullptr if it does not. More...
|
|
bool | getRemove (const Key &key, Key &removedKey, Value &removedValue) |
| If member is present, sets removed to the element being removed and returns true. More...
|
|
void | getValues (Array< Value > &valueArray) const |
| Will contain duplicate values if they exist in the table. More...
|
|
template<class H , class E > |
bool | operator!= (const Table< Key, Value, H, E > &other) const |
|
SmallTable & | operator= (const ThisType &h) |
|
template<class H , class E > |
bool | operator== (const Table< Key, Value, H, E > &other) const |
|
Value & | operator[] (const Key &key) const |
|
Short syntax for get. More...
|
|
bool | remove (const Key &key) |
|
Removes an element from the table if it is present. More...
|
|
void | set (const Key &key, const Value &value) |
|
If you insert a pointer into the key or value of a table, you are responsible for deallocating the object eventually. More...
|
|
void | setSizeHint (size_t n) |
|
Recommends that the table resize to anticipate at least this number of elements. More...
|
|
size_t | size () const |
|
Returns the number of keys. More...
|
|
template<class Key, class Value, class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
class G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >
An unordered data structure mapping keys to values; maintained behind the scenes in a linear array
- See also
- G3D::Table
template<class Key , class Value , class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
template<class Key , class Value , class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
Calls delete on all of the values.
This is unsafe– do not call unless you know that each value appears at most once.
Does not clear the table, so you are left with a table of nullptr pointers.
template<class Key , class Value , class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
bool G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::get |
( |
const Key & |
key, |
|
|
Value & |
val |
|
) |
| const |
|
inline |
If the key is present in the table, val is set to the associated value and returns true.
If the key is not present, returns false.
template<class Key , class Value , class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
Value* G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getPointer |
( |
const Key & |
key | ) |
const |
|
inline |
Returns a pointer to the element if it exists, or nullptr if it does not.
Note that if your value type is a pointer, the return value is a pointer to a pointer. Do not remove the element while holding this pointer.
It is easy to accidentally mis-use this method. Consider making a Table<Value*> and using get(key, val) instead, which makes you manage the memory for the values yourself and is less likely to result in pointer errors.
Referenced by G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::get().
template<class Key , class Value , class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
bool G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::getRemove |
( |
const Key & |
key, |
|
|
Key & |
removedKey, |
|
|
Value & |
removedValue |
|
) |
| |
|
inline |
If member is present, sets removed to the element being removed and returns true.
Otherwise returns false and does not write to removed.
template<class Key , class Value , class HashFunc = HashTrait<Key>, class EqualsFunc = EqualsTrait<Key>>
void G3D::SmallTable< Key, Value, HashFunc, EqualsFunc >::set |
( |
const Key & |
key, |
|
|
const Value & |
value |
|
) |
| |
|
inline |
If you insert a pointer into the key or value of a table, you are responsible for deallocating the object eventually.
Inserting key into a table is O(1), but may cause a potentially slow rehashing.