Product SiteDocumentation Site

5.3. The Collection Classes

A collection is an object that contains a number of items, which can be any objects. 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 [] methods.
Each collection defines its own acceptable index types. Rexx provides the following collection classes:
Array (Section 5.3.6, “The Array Class”)
A sequenced collection of objects ordered by whole-number indexes.
Bag (Section 5.3.7, “The Bag Class”)
A collection where the index and the item are the same object. Bag indexes can be any object and each index can appear more than once.
CircularQueue (Section 5.3.8, “The CircularQueue Class”)
The CircularQueue class allows for storing objects in a circular queue of a predefined size. Once the end of the queue has been reached, new item objects are inserted from the beginning, replacing earlier entries. The collected objects can be processed in FIFO (first in, first out) or in a stack-like LIFO (last in, first out) order.
Directory (Section 5.3.9, “The Directory Class”)
A collection with character string indexes. Index comparisons are performed using the string == comparison method.
List (Section 5.3.10, “The List Class”)
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.
Properties (Section 5.3.11, “The Properties Class”
A collection with character string indexes and values. Properties collections include support for saving and loading from disk files.
Queue (Section 5.3.12, “The Queue Class”)
A sequenced collection with the items ordered as a queue. You can remove items from the head of the queue and add items 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.
Relation (Section 5.3.13, “The Relation Class”)
A collection with indexes that can be any object. A relation can contain duplicate indexes.
Set (Section 5.3.14, “The Set Class”)
A collection where the index and the item are the same object. Set indexes can be any object and each index is unique.
Stem (Section 5.3.15, “The Stem Class”)
A collection with character string indexes constructed from one or more string segments. Index comparisons are performed using the string == comparison method.
Table (Section 5.3.16, “The Table Class”)
A collection with indexes that can be any object. A table contains no duplicate indexes.
IdentityTable (Section 5.3.17, “The IdentityTable Class”)
A collection with indexes that can be any object. The IdentityTable class determines index item matches by using an object identity comparison. With object identity matches, an index will only match the same object instance. An identity table contains no duplicate indexes.

5.3.1.  Organization of the Collection Classes

The following shows the logical organization of the Collection Classes. This does NOT represent the order that methods are inherited but rather the organization of the classes.
Collection (Section 5.3.2, “The Collection Class”)
   MapCollection (Section 5.3.3, “The MapCollection Class”)
      Directory (Section 5.3.9, “The Directory Class”)
      Properties (Section 5.3.11, “The Properties Class”)
      Releation (Section 5.3.13, “The Relation Class”)
      Stem (Section 5.3.15, “The Stem Class”)
      Table (Section 5.3.16, “The Table Class”)
      IdentityTable (Section 5.3.17, “The IdentityTable Class”)
   OrderedCollection (Section 5.3.4, “The OrderedCollection Class”)
      Array (Section 5.3.6, “The Array Class”)
      List (Section 5.3.10, “The List Class”)
      Queue (Section 5.3.12, “The Queue Class”)
      CircularQueue (Section 5.3.8, “The CircularQueue Class”)
   SetCollection (Section 5.3.5, “The SetCollection Class”)
      Bag (Section 5.3.7, “The Bag Class”)
      Set (Section 5.3.14, “The Set Class”)