#include <rw/tpsldict.h> RWTPtrSlistDictionary<KP,VP> slistDict;
This class maintains a pointer-based collection of values, implemented as an intrusive singly-linked list of key and value pairs. Class KP is the type pointed to by the key part of the pairs, and is used for lookup. Class VP is the type pointed to by the value part of the pairs.
Isomorphic
This class is used in the implementation of RWTPtrHashDictionary.
RWTPtrSlistDictionary<KP,VP>();
Constructs an empty, singly-linked dictionary to hold pointers to KP and VP types.
RWTPtrSlist<KP,VP>(const RWTPtrSlistDictionary<KP,VP>&);
Copy constructor.
RWTPtrSlistDictionary<KP,VP>& operator=(const RWTPtrSlistDictionary<KP,VP>& lst);
Empties self, then inserts all elements of lst.
VP*& operator[](KP *key);
Returns a reference to the value associated with key. If there is no element with key key, then a new association with that key and a nil pointer value is created and inserted into self.
void applyToKeyAndValue(void (*appFn)(KP*, VP*&, void*), void* d);
Applies the user-defined function pointed to by appFn to every item in the collection. Client data may be passed through parameter d.
clear();
Clears the collection by removing all pairs from self.
void clearAndDestroy();
Removes all items from the collection and uses operator delete to destroy the objects pointed to by those items. Do not use this method if multiple pointers to the same object are stored.
RWBoolean contains(const KP* a) const;
Returns TRUE if there exists a pair in self with key k such that the expression(*k == *a) is TRUE. Otherwise, returns FALSE.
size_t entries() const;
Returns the number of items in self.
KP* find(const KP* a) const;
If there exists a pair in self with key k such that the expression (*k == *a) is TRUE, returns k. Otherwise, returns rwnil.
KP* findKeyAndValue(const KP* a, VP*& retval) const;
If there exists a pair in self with key k such that the expression (*k == *a) is TRUE, places the value part of the pair in retval and returns k. Otherwise, returns rwnil.
VP* findValue(const KP* a) const;
If there exists a pair in self with key k such that the expression (*k == *a) is TRUE, returns the value part of the pair. Otherwise, returns rwnil.
void insertKeyAndValue(KP* k, VP* v);
If find(k) would fail, inserts a new pair holding k and v; otherwise, replaces with v the value associated with k.
RWBoolean isEmpty() const;
Returns TRUE if there are no items in the collection, FALSE otherwise.
KP* remove(const KP* k);
If find(k) would succeed, removes the pair associated with k, and returns the key part. Otherwise, returns rwnil.
KP* removeKeyAndValue(const KP* k VP*& retVal);
If find(k) would succeed, removes the pair associated with k, places the value part in retVal, and returns the key part. Otherwise, returns rwnil.