ADTDictionary
Dictionary which implementes an hash table.
If life time handling of allocated keys and values is needed the callback procedures duplicateKey/Value and disposeKey/Value can be used.
By default the dictionary only takes references of keys & elements and the caller is responsible for keeping them alive.
Types
DuplicateKeyProc* = PROCEDURE(VAR dst: Key;
Procedures
DefaultDuplicateKey
defaults to assignment
PROCEDURE DefaultDuplicateKey* (VAR dst: Key; src-: Key);
DefaultDisposeKey
defaults to no operation
PROCEDURE DefaultDisposeKey* (VAR dst: Key);
DefaultDuplicateValue
defaults to assignment
PROCEDURE DefaultDuplicateValue* (VAR dst: Value; src-: Value);
DefaultDisposeValue
defaults to no operation
PROCEDURE DefaultDisposeValue* (VAR dst: Value);
Dictionary.Init
Initialize set storage to given capacity. Capacity will be rounded up to nearest exponent of 2 size.
PROCEDURE (VAR this : Dictionary) Init*(capacity : LENGTH);
Dictionary.Dispose
Free dictionary storage
PROCEDURE (VAR this : Dictionary) Dispose*();
Dictionary.Size
Return size of dictionary
PROCEDURE (VAR this- : Dictionary) Size*(): LENGTH;
Dictionary.HasKey
Return TRUE if dictionary has item with given key
PROCEDURE (VAR this- : Dictionary) HasKey*(key- : Key): BOOLEAN;
Dictionary.Set
Set or update item with given key to value
PROCEDURE (VAR this : Dictionary) Set* (key- : Key; value- : Value);
Dictionary.Get
Get value and return TRUE if dictionary has item with given key. Note: this potentially return a reference to the value.
PROCEDURE (VAR this- : Dictionary) Get*(key- : Key; VAR value : Value): BOOLEAN;
Dictionary.Remove
Remove item from dictionary. Return TRUE if item present and was removed
PROCEDURE (VAR this : Dictionary) Remove*(key- : Key): BOOLEAN;
Dictionary.Discard
Remove item from dictionary if present
PROCEDURE (VAR this : Dictionary) Discard*(key- : Key);
Dictionary.Clear
Clears all items without deallocation
PROCEDURE (VAR this : Dictionary) Clear*();
Dictionary.Pop
Remove arbitary item from dictionary and set key. Return FALSE if dictionary is empty. Note: this potentially transfere key ownership to caller.
PROCEDURE (VAR this : Dictionary) Pop*(VAR key : Key): BOOLEAN;
Dictionary.PopItem
Remove arbitary item from dictionary and set key and value to item. Return FALSE if dictionary is empty. Note: this potentially transfere key and value ownership to caller.
PROCEDURE (VAR this : Dictionary) PopItem*(VAR key : Key; VAR value : Value): BOOLEAN;
Dictionary.Keys
Return Vector of keys. Note: this potentially return a vector of reference to keys.
PROCEDURE (VAR this- : Dictionary) Keys*(): KeyVector;
Dictionary.Values
Return Vector of values. Note: this potentially return a vector of reference to the values.
PROCEDURE (VAR this- : Dictionary) Values*(): ValueVector;
Dictionary.First
Returns an iterator for the dictionary.
PROCEDURE (VAR this- : Dictionary) First* (VAR iterator: Iterator);
Iterator.Next
Advance iterator and set key. Return FALSE if end is reached. Note: this potentially set the key to a reference.
PROCEDURE (VAR this : Iterator) Next*(VAR key : Key) : BOOLEAN;
Iterator.NextItem
Advance iterator and set key and value. Return FALSE if end is reached. Note: this potentially set the key and value to a reference.
PROCEDURE (VAR this : Iterator) NextItem*(VAR key : Key; VAR value : Value) : BOOLEAN;
Iterator.Reset
Reset iterator to start of set.
PROCEDURE (VAR this : Iterator) Reset*();