Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Object REXX
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Collection classes === A collection is an object that contains multiple items with associated indexes that enable items to be retrieved using the <code>AT</code> or <code>[]</code> methods. There are MapCollection, SetCollection and OrderedCollection classes, all of which allow manipulation of a specific collection type.<ref name=":9" /> A MapCollection is a mixin class that defines the basic set of methods implemented by all collections that map from an index to a value. The <code>Directory</code>, <code>StringTable</code>, <code>IdentityTable</code>, <code>Properties</code>, <code>Table</code>, <code>Relation</code> and <code>Stem</code> classes inherit these methods.<ref name=":2" /> A Directory or a StringTable object is a collection of unique string indexes. In an IdentityTable object, each item is associated with a single index, and there can only be one item for each index. The Properties object provides specific methods for saving and loading properties into files. Unlike a Table object, which cannot contain duplicate indexes, a Relation object is a collection in which elements can have the same index, which can be of any object type. A Stem object is created automatically when a compound variable is used. As in classic Rexx, such a variable consists of a stem and a tail, separated by a dot (<code>.</code>). While the stem must begin with a letter, the tail can be any character. Using a single numeric tail creates the same effect as an [[Array (data type)|array]], while multiple numeric tails can be used to create a multidimensional array.<ref name=":2" /><ref name=":9" /><syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1">fruits.1 = "Apple" /* assigning to stem variable */ fruits.4 = "Orange" /* assigning to stem variable */ say fruits.4 /* output: Orange */ say fruits.[1] /* output: Apple */</syntaxhighlight>SetCollections are special types of MapCollections where the index and the element are the same object. While the indexes in a <code>Set</code> object are unique, each index in a <code>Bag</code> object can appear more than once.<ref name=":2" /> An OrderedCollection is a mixin class that defines the basic methods for all collections that have an inherent index order, such as the <code>List</code>, <code>Queue</code>, <code>CircularQueue</code> and <code>Array</code> classes. A List object allows new items, for which a new index is created, to be added at any position in a collection. The associated index remains valid for that item regardless of other additions or removals. A Queue object allows items to be removed from the head and added to the tail or head of the queue. A CircularQueue object is a queue with a predefined size. Once the end of the circular queue is reached, new elements are inserted from the beginning to replace the previous items.<ref name=":2" /><ref name=":9" /> An Array is sequenced collection ordered by whole-number indexes. Like some other collection classes, the <code>Array</code> class provides the <code>MAKESTRING</code> method to encode its elements as a string object.<ref name=":2" /> <syntaxhighlight lang="oorexx" style="background-color: #ffffff; !important" line="1"> ArrayObj = .array~of("One", "Two", "Three") /* array with 3 items */ say ArrayObj~at(2) /* output: Two */ say ArrayObj~makeString(,"; ") /* output: One; Two; Three */ </syntaxhighlight>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)