Go to the previous, next section.
#include <nihcl/IdentDict.h>
An
IdentDict
(Identity Dictionary) is similar to a
Dictionary
, except that it uses
isSame()
for comparing key objects instead of
isEqual()
. Instances of class
IdentDict
are useful for "hash linking" additional information to an object. For example, the object I/O
storeOn()
function uses an
IdentDict
to record which objects within a complex data structure have already been stored, in order to be able to resolve multiple references to an object.
IdentDict(unsigned
capacity
=DEFAULT_CAPACITY)
IdentDict
that can hold up to
capacity
associations (instances of classes derived from
LookupKey
). If an attempt is made to add more than
capacity
associations,
reSize()
is called to increase the
IdentDict
's capacity. Since this is an expensive operation, it is wise to supply a reasonable estimate for
capacity.
virtual LookupKey* assocAt(const Object&
key) const
IdentDict
with the key object
key. If
key
is not found,
assocAt()
returns 0.
virtual Object* atKey(const Object&
key) const
IdentDict
whose key object is the same as
key. If
key
is not found,
atKey()
raises an
NIHCL_KEYNOTFOUND
exception.
virtual Object* atKey(const Object&
key, Object&
newValue)
IdentDict
with key
key
to
newValue
and returns a pointer to the old value object. If
key
is not found,
atKey()
raises an
NIHCL_KEYNOTFOUND
exception.
virtual bool includesKey(const Object&
key) const
YES
if there is an association in this
IdentDict
with the key object
key.
virtual int findIndexOf(const Object&
lkey) const
IdentDict
for a key object that is the same (i.e.
isSame()
) as the key object of the
LookupKey
lkey
and returns the index of this object, if found, or the index of an empty slot in the hash table where
lkey
should be inserted.
virtual unsigned hashOf(const Object&
lkey) const
LookupKey
lkey.
Go to the previous, next section.