83 map.set(key, newValue);
103 return map.remove(key);
113 return map.extract(key);
202 return Value(*
this, key);
209 void set(
const K& key, V* value)
215 entries.addElement(
new Entry(key, value));
228 return (index < 0) ? nullptr :
entries[index].value.get();
238 for(
unsigned i = 0; i <
entries.count(); i++) {
270 bool remove(
const K& key)
301 std::unique_ptr<V> value;
303 entries[index].value.swap(value);
306 return value.release();
325 Entry(
const K& key, V* value) : key(key)
327 this->value.reset(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:111
Vector< Entry > entries
Definition: ObjectMap.h:331
Implementation of a HashMap for owned objects, i.e. anything created with new().
Definition: ObjectMap.h:48
K & keyAt(unsigned idx)
Definition: ObjectMap.h:145
Value valueAt(unsigned idx)
Definition: ObjectMap.h:167
Vector class template.
Definition: WVector.h:31
std::unique_ptr< V > value
Definition: ObjectMap.h:323
Class to provide safe access to mapped value.
Definition: ObjectMap.h:64
const V * operator[](const K &key) const
Get value for given key, if it exists.
Definition: ObjectMap.h:178
unsigned count() const
Get the number of entries in this map.
Definition: ObjectMap.h:125
Value operator[](const K &key)
Access map entry by reference.
Definition: ObjectMap.h:190
K key
Definition: ObjectMap.h:322
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:76
const V * valueAt(unsigned idx) const
Definition: ObjectMap.h:156
ObjectMap()
Definition: ObjectMap.h:51
~ObjectMap()
Definition: ObjectMap.h:55
void clear()
Clear the map of all entries.
Definition: ObjectMap.h:312
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:92
const K & getKey() const
Definition: ObjectMap.h:71
Entry(const K &key, V *value)
Definition: ObjectMap.h:325
An entry in the ObjectMap.
Definition: ObjectMap.h:321
const K & keyAt(unsigned idx) const
Definition: ObjectMap.h:135
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:67
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:81