The Collection Classes
Some potentially very useful classes for programmers are those for defining
collections of objects that require manipulation. A collection is
an object that contains a number of items, which can be any objects.
These manipulations might include counting objects, organizing them, or
assigning them a supplier (for example, to indicate that a specific assortment
of baked goods is supplied by the Pie-by-Night Bakery). The classes that
enable such manipulations are called collection classes.
REXX includes classes for arrays, lists, queues, tables, directories, and
the like. Every item stored in a REXX collection has an associated index
that you can use to retrieve the item from the collection with the AT or
[] (left and right bracket) methods, and each collection defines its own
acceptable index types:
Array
A sequenced collection of objects ordered
by whole number indexes.
List
A
sequenced collection that lets you add new items at any position in the
sequence. A list generates and returns an index value for each item placed
in the list. The returned index remains valid until the item is removed
from the list.
Queue
A sequenced
collection with the items ordered as a queue. You can remove items from
the head of the queue and add at either its tail or its head. Queues index
the items with whole number indexes, in the order in which the items would
be removed. The current head of the queue has index 1, the item after the
head item has index 2, up to the number of items in the queue.
Table
A collection with indexes that can be any object.
For example, string objects, array objects, alarm objects, or any user-created
object can be a table index. The Table class determines index match by
using the == comparison method to test for strict equality. A table contains
no duplicate indexes.
Directory
A
collection with character string indexes. Index comparisons are performed
using the string == comparison method to test for strict equality.
Relation
A collection with indexes that can be any object
(as with the Table class). A relation can contain duplicate indexes.
Set
A collection where the indexes and the values are
the same object. Set indexes can be any object (as with the Table class)
and each index is unique.
Bag
A
collection where the index and the value are the same object. Bag indexes
may be any object (as with the Table class) and each index may appear more
than once.
[Back: The Alarm Class]
[Next: The Message Class]