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.
Procedures
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 set 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 may be duplicate the value and the caller would be responsible for the lifetime of 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 may be duplicate the key and the caller would be responsible for the lifetime of the key.
PROCEDURE (VAR this : Dictionary) Pop*(VAR key : Key): BOOLEAN;
Dictionary.PopItem
Remove arbitary item from dictionary and set key and value. Return FALSE if dictionary is empty. Note this may be duplicate the key and/or value and the caller would be responsible for the lifetime.
PROCEDURE (VAR this : Dictionary) PopItem*(VAR key : Key; VAR value : Value): BOOLEAN;
Dictionary.Keys
Return Vector of keys. Note this may be duplicate the keys and the caller would be responsible for the lifetime of the keys.
PROCEDURE (VAR this- : Dictionary) Keys*(): KeyVector;
Dictionary.Values
Return Vector of values. Note this may be duplicate the values and the caller would be responsible for the lifetime of 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 may be duplicate the key and the caller would be responsible for the lifetime of the key.
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 may be duplicate the key and/or value and the caller would be responsible for the lifetimes.
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*();