|
void | clear () |
| Erases all entries in the hash map.
|
|
SBCContainerHashMapEntry< KeyType, ValueType > * | insert (const KeyType &key, const ValueType &value) |
| Inserts an element in the hash map.
|
|
bool | erase (const KeyType &key) |
| Attempts to erase an entry with a specific key and returns true if successful.
|
|
bool | hasValue (const KeyType &key) const |
| Returns true if the key has an associated value.
|
|
bool | getValue (const KeyType &key, ValueType &value) const |
| Returns true if the key has an associated value and puts it in the value, else returns false.
|
|
std::optional< ValueType > | getValue (const KeyType &key) const |
| Returns the value associated to the key if found.
|
|
unsigned int | size () const |
| The number of entries in the hash map.
|
|
bool | empty () const |
| Returns true when the hash map contains no entry.
|
|
|
iterator | begin () |
| Returns an iterator that points to the beginning of the hash map.
|
|
const_iterator | begin () const |
| Returns an iterator that points to the beginning of the hash map.
|
|
ValueType & | operator[] (const KeyType &key) |
| Returns a reference to the value mapped to the key, which is inserted if necessary.
|
|
iterator | find (const KeyType &key) |
| Finds a key in the hash map.
|
|
const_iterator | find (const KeyType &key) const |
| Finds a key in the hash map.
|
|
iterator | end () |
| Returns an iterator that points to the end of the hash map.
|
|
const_iterator | end () const |
| Returns an iterator that points to the end of the hash map.
|
|
std::map< KeyType, ValueType > | toStdMap () const |
| Returns a std map containing the same (key, value) pairs.
|
|
template<class KeyType, class ValueType, class HashMapFunctor = SBCContainerHashMapFunctor<KeyType>, class KeyComparator = SBCContainerHashMapKeyComparator<KeyType>>
class SBCContainerHashMap< KeyType, ValueType, HashMapFunctor, KeyComparator >
- Parameters
-
KeyType | The type of keys |
ValueType | The type of values |
HashMapFunctor | The hash map functor, used to hash keys (by default, this is a SBCContainerHashMapFunctor<KeyType>) |
KeyComparator | The key comparator, used to compare keys (by default, this is a SBCContainerHashMapKeyComparator<KeyType>) |
This template class describes a hashtable-based map. This container is used for example to index objects (see SBCContainerIndexer), and may be used to efficiently map keys to values:
SBVector<SBAtom*> v;
SBHashMap<SBAtom*, unsigned int> h;
for (unsigned int i = 0; i<10; i++) {
h.insert(v[i], 6 * i + 17)
}
unsigned int j = 0;
for (unsigned int i = 0; i < 10; i++)
if (h.getValue(v[i], j)) std::cout << j << '\n';
SBMStructuralModelNodeAtom SBAtom
The short name of SBMStructuralModelNodeAtom.
Definition: SBMStructuralModelNodeAtom.hpp:666
@ Carbon
The type of the Carbon element.
Definition: SBMElement.hpp:48
Short name: SBHashMap
- See also
- SB_FOR