Oberon || Library || Module Index || Search Engine || Definition || Module


Ulm's Oberon Library:
Arrays


NAME

Arrays - associative arrays

SYNOPSIS

CONST ascending = 0;  (* in ascending order *)
CONST descending = 1; (* in descending order *)
TYPE Order = Iterators.Mode;    (* ascending, descending *)


TYPE Array = POINTER TO ArrayRec; TYPE ArrayRec = RECORD (Services.ObjectRec) END;

PROCEDURE Create(VAR array: Array; key: Keys.Key); PROCEDURE GetKey(array: Array; VAR key: Keys.Key); PROCEDURE Set(array: Array; keyval: Keys.Value; object: Objects.Object); PROCEDURE Get(array: Array; keyval: Keys.Value; VAR object: Objects.Object) : BOOLEAN; PROCEDURE Remove(array: Array; keyval: Keys.Value); PROCEDURE Exists(array: Array; keyval: Keys.Value) : BOOLEAN; PROCEDURE Card(array: Array) : INTEGER; PROCEDURE GetKeys(array: Array; order: Order; from, to: Keys.Value; VAR it: Iterators.Iterator); PROCEDURE GetEntries(array: Array; order: Order; from, to: Keys.Value; VAR it: Iterators.Iterator);

DESCRIPTION

Arrays provides sorted associative arrays (on base of AVLTrees) where objects do not need to include their key values.

Create creates an array with key as sorting key. GetKey returns the key previously passed to Create.

Set sets the object of the array associated with keyval to object. This causes previous associations of keyval, if any, to be lost. Note that object must not be NIL. Get retrieves the object of the array associated with keyval. FALSE is returned, if no such association exists. Remove removes the association of keyval within array, if any. Exists returns TRUE if array includes an object associated with keyval. Card returns the number of associations within array.

GetKeys returns an iterator that generates the keys of the array, beginning from from up to and including to in sorted order. NIL may be given to designate the lowest or highest key value, respectively. GetEntries works similarly but returns the corresponding objects.

DIAGNOSTICS

Arrays does not generate error events on its own. Events by the underlying AVLTrees implementation are forwarded to the array object.

SEE ALSO

AVLTrees
the underlying implementation which provides sorted trees for objects that include their key values and unique keys
SortedBags
sorted trees for objects that include their key values but where keys do not need to be unique

Edited by: borchert, last change: 2004/03/19, revision: 1.1, converted to HTML: 2004/03/19

Oberon || Library || Module Index || Search Engine || Definition || Module