Oberon || Library || Module Index || Search Engine || Definition || Module
CONST ascending = 0; (* in ascending order *) CONST descending = 1; (* in descending order *) TYPE Order = Iterators.Mode; (* ascending, descending *) TYPE Bag = POINTER TO BagRec; TYPE BagRec = RECORD (Services.ObjectRec) END;
PROCEDURE Create(VAR bag: Bag; key: Keys.Key); PROCEDURE GetKey(bag: Bag; VAR key: Keys.Key); PROCEDURE Add(bag: Bag; object: Services.Object); PROCEDURE Remove(bag: Bag; object: Services.Object); PROCEDURE Card(bag: Bag): INTEGER; PROCEDURE GetEntries(bag: Bag; order: Order; from, to: Keys.Value; VAR it: Iterators.Iterator);
Create creates a sorted bag with key as sorting key. GetKey returns the key previously passed to Create.
Add adds object to bag. Note that it is a fatal error (assertion failed) if object does not support the sorting key of bag. Remove removes object from bag if it belongs to it. Card returns the number of objects stored in bag. GetEntries creates an iterator that returns all objects ranging from from to to in sorted order ascending or descending according to order. In case of identical key values the order is defined by the time of addition. Note that from and to may be NIL to specify the lowest or highest key of bag, respectively.
Oberon || Library || Module Index || Search Engine || Definition || Module