82 map.set(key, newValue);
102 return map.remove(key);
112 return map.extract(key);
201 return Value(*
this, key);
208 void set(
const K& key, V* value)
215 entries.addElement(
new Entry(key, value));
228 return (index < 0) ? nullptr :
entries[index].value;
238 for(
unsigned i = 0; i <
entries.count(); i++) {
270 bool remove(
const K& key)
304 entries[index].value =
nullptr;
326 Entry(
const K& key, V* value) : key(key), value(value)
void removeAt(unsigned index)
Remove entry at given index.
Definition: ObjectMap.h:260
V * extract()
Get the value for a given key and remove it from the map, without destroying it.
Definition: ObjectMap.h:110
Vector< Entry > entries
Definition: ObjectMap.h:336
Implementation of a HashMap for owned objects, i.e. anything created with new().
Definition: ObjectMap.h:47
K & keyAt(unsigned idx)
Definition: ObjectMap.h:144
Value valueAt(unsigned idx)
Definition: ObjectMap.h:166
Vector class template.
Definition: WVector.h:29
Class to provide safe access to mapped value.
Definition: ObjectMap.h:63
const V * operator[](const K &key) const
Get value for given key, if it exists.
Definition: ObjectMap.h:177
unsigned count() const
Get the number of entries in this map.
Definition: ObjectMap.h:124
Value operator[](const K &key)
Access map entry by reference.
Definition: ObjectMap.h:189
K key
Definition: ObjectMap.h:323
~Entry()
Definition: ObjectMap.h:330
bool contains(const K &key) const
Check if a key is contained within this map.
Definition: ObjectMap.h:251
V * getValue() const
Definition: ObjectMap.h:75
const V * valueAt(unsigned idx) const
Definition: ObjectMap.h:155
ObjectMap()
Definition: ObjectMap.h:50
~ObjectMap()
Definition: ObjectMap.h:54
void clear()
Clear the map of all entries.
Definition: ObjectMap.h:313
V * extractAt(unsigned index)
Get the value at a given index and remove it from the map, without destroying it. ...
Definition: ObjectMap.h:299
int indexOf(const K &key) const
Get the index of a key.
Definition: ObjectMap.h:236
V * operator->() const
Definition: ObjectMap.h:91
const K & getKey() const
Definition: ObjectMap.h:70
Entry(const K &key, V *value)
Definition: ObjectMap.h:326
An entry in the ObjectMap.
Definition: ObjectMap.h:322
const K & keyAt(unsigned idx) const
Definition: ObjectMap.h:134
V * extract(const K &key)
Get the value for a given key and remove it from the map, without destroying it.
Definition: ObjectMap.h:287
Value(ObjectMap< K, V > &map, const K &key)
Definition: ObjectMap.h:66
V * find(const K &key) const
Find the value for a given key, if it exists.
Definition: ObjectMap.h:225
Value & operator=(V *newValue)
Definition: ObjectMap.h:80