ADTSet

Set type implementation based on a hash table.

If life time handling of allocated of elements is needed the callback procedures duplicate and dispose can be used.

By default the set only takes references of elements and the caller is responsible for keeping elements alive.

Procedures

Set.Init

Initialize set storage to given capacity. Capacity will be rounded up to nearest exponent of 2 size.

PROCEDURE (VAR this : Set) Init*(capacity : LENGTH);

Set.Dispose

Free set storage

PROCEDURE (VAR this : Set) Dispose*();

Set.Size

Return size of set

PROCEDURE (VAR this- : Set) Size*(): LENGTH;

Set.In

Return TRUE if set has given element

PROCEDURE (VAR this- : Set) In*(element- : Element): BOOLEAN;

Set.Incl

Add element to set

PROCEDURE (VAR this : Set) Incl* (element- : Element);

Set.Excl

Remove element from set.

PROCEDURE (VAR this : Set) Excl*(element- : Element);

Set.Clear

Clear set all elements without deallocation

PROCEDURE (VAR this : Set) Clear*();

Set.Pop

Remove arbitary element from set. Return FALSE if set is empty. Note this may be duplicate the element and the caller would be responsible for the lifetime of the element.

PROCEDURE (VAR this : Set) Pop*(VAR element : Element): BOOLEAN;

Set.Elements

Return Vector of elements. Note this may be duplicate the elements and the caller would be responsible for the lifetime of the elements.

PROCEDURE (VAR this- : Set) Elements*(): ElementVector;

Set.First

Returns an iterator for the set.

PROCEDURE (VAR this- : Set) First* (VAR iterator: Iterator);

Iterator.Next

Advance iterator. Return FALSE if end is reached. Note this may be duplicate the element and the caller would be responsible for the lifetime of the element.

PROCEDURE (VAR this : Iterator) Next*(VAR element : Element) : BOOLEAN;

Iterator.Reset

Reset iterator to start of set.

PROCEDURE (VAR this : Iterator) Reset*();