---
rexxpub:
  defaults: rony.yaml
  logo: oorexx
---

<!-- 051_ooRexx_V12.odp (2026-10-15 09:36) -->

<!-- slide # 1 (2026-10-15 09:36) ----------------------------- ODP slide # 1 -->
. slide cover
# Procedural and Object-oriented Programming 5b

. subtitle
**Object Rexx Collection Classes**

. cover-art
. picture img/051_ooRexx_V12/p01-diagram-7.png

<!-- slide # 2 (2026-10-15 09:36) ----------------------------- ODP slide # 2 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.2. Collection Class)"
# Collection Classes

. after steps
- An overview of collection classes
    . after
    - Hint: ooRexx comes with more collection classes than get demonstrated here
- Common methods of collection classes
- Iterating over collected objects
    . after
    - Differences between ordered and unordered collection classes
- Collections with setlike methods

<!-- slide # 3 (2026-10-15 09:36) ----------------------------- ODP slide # 3 -->
. slide kicker="Classification Tree (ooRexx 3.1)" reference="Cf. rexxref.pdf (5. Builtin Classes, 5.3.2. Collection Class)"
# Collection Classes

. mark id=#t1 "Array" "List" "Queue" "CircularQueue" "Directory" "Relation" "Bag" "Table" "Set"
. mark id=#t2 "Stem" "Stream"
. tree layout=columns flow=4
- Object
  - Class
  - Method
  - Message
  - Alarm
  - Monitor
  . break
  - String
  - Stem
  - Stream
  - MutableBuffer
  . break
  - Array
  - List
  - Queue
    . under
    - CircularQueue
  - Supplier
  . break
  - Directory
  - Relation
    - Bag
  - Table
    - Set

. after show #t1 hull

. after show #t2 hull hatch

<!-- slide # 4 (2026-10-15 09:36) ----------------------------- ODP slide # 4 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3. Collection Classes)"
# Collection Classes

. after steps
- Collection classes allow collecting Object Rexx objects
- The following methods are available
    . after
    - **PUT** or the synonym "**\[ \]=**" collects (stores) an object with an index

      . after
      ```rexx
      collectionObject ~PUT(object,index)
      collectionObject ~"[]="(object,index)
      collectionObject[index] = object
      ```

    - **AT** or the synonym "**\[ \]**" retrieves an object from a collection by its index

      . after
      ```rexx
      collectionObject ~AT(index)
      collectionObject ~"[]"(index)
      collectionObject[index]
      ```

<!-- slide # 5 (2026-10-15 09:36) ----------------------------- ODP slide # 5 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3. Collection Classes)"
# Collection Classes

. after steps
- Collection classes allow the use of the class method **OF** supplying a list of objects for the collection instead of the class method **NEW**.
- Iterating over the collection using a **DO...OVER** block statement

  . after
  ```rexx
  DO i OVER tmpColl
     SAY "[" || i || "]"
  END
  ```

- Iterating over the collection using a **SUPPLIER** object (see below)

<!-- slide # 6 (2026-10-15 09:36) ----------------------------- ODP slide # 6 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3. Collection Classes)"
# Collection Classes

. steps each=after
- One can divide collection classes in two groups
    - Ordered collection
        - Collection classes **without** a user defined index
    . click
    - Unordered collection
        - Collection classes **with** a user defined index
. click
- Ordered collection classes (without a user defined index)
    - **Array**
    . with
    - **List**
    . with
    - **Queue, CircularQueue**
    . with
    - **(Stream)**

<!-- slide # 7 (2026-10-15 09:36) ----------------------------- ODP slide # 7 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.6. Array Class)"
# Collection Classes – Ordered Collection

- **Array**
    . after
    - Array objects allow the storing of objects with a pre-defined numeric index, which must be a whole number starting with the value 1

      . click
      ```rexx
      tmpColl = .array ~of("a", "b", "b")
      tmpColl[4] = "c"

      SAY tmpColl~string":"
      DO i OVER tmpColl
         SAY "["i"]"
      END
      ```

      . click label
      Output:

      . after
      ```output
      an Array:
      [a]
      [b]
      [b]
      [c]
      ```

<!-- slide # 8 (2026-10-15 09:36) ----------------------------- ODP slide # 8 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.6. Array Class)"
# Collection Classes – Ordered Collection

- **Array**
    . after
    - Array objects can possess arbitrary many dimensions
        . after
        - Hint: the needed memory is the Cartesian product of the maximum number of entries of each dimension

. click level=2
```rexx
tmpColl = .array ~new
tmpColl[2,3] = "a"
tmpColl ~"[]="("b", 1, 1)
tmpColl ~~put("b", 4, 5) ~~put("c", 1, 2)

SAY tmpColl~string":"
DO i OVER tmpColl
   SAY "["i"]"
END
```

. click label level=2
Output:

. after level=2
```output
an Array:
[b]
[c]
[a]
[b]
```

<!-- slide # 9 (2026-10-15 09:36) ----------------------------- ODP slide # 9 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.11. List Class)"
# Collection Classes – Ordered Collection

- **List**
    . after
    - List objects allow the storing of objects (instances, values) in the form of a list, i.e. in an ordered manner

      . click
      ```rexx
      tmpColl = .list ~of("a", "b", "b", "c")

      SAY tmpColl~string":"
      DO i OVER tmpColl
         SAY "["i"]"
      END
      ```

      . click label
      Output:

      . after
      ```output
      a List:
      [a]
      [b]
      [b]
      [c]
      ```

<!-- slide # 10 (2026-10-15 09:36) --------------------------- ODP slide # 10 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.13. Queue Class, 5.3.8. CircularQueue Class)"
# Collection Classes – Ordered Collection

- **Queue, CircularQueue**
    . after
    - Queue objects allow the storing of objects (instances, values) at the "head" (**PUSH**) or at the "tail" (**QUEUE**), i.e. in an ordered manner

      . click
      . after mark 2 '~~push("b") ~push("c")' pen=1
      ```rexx
      tmpColl = .queue ~new
      tmpColl ~~queue("a") ~~queue("b") ~~push("b") ~push("c")

      SAY tmpColl~string":"
      DO i OVER tmpColl
         SAY "["i"]"
      END
      ```

      . click label
      Output:

      . after
      . after mark 2-3 pen=2
      ```output
      a Queue:
      [c]
      [b]
      [a]
      [b]
      ```

<!-- slide # 11 (2026-10-15 09:36) --------------------------- ODP slide # 11 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.2.4. Stream Class)"
# Collection Classes – Ordered Collection

- **Stream**
    . after
    - Stream objects allow the processing of streams of "lines" or "characters"
        . click
        - With the help of the stream object one is able to process the file "myinput.txt", by sending the stream object the appropriate messages, for instance: **OPEN**, **LINEIN** (**CHARIN**), **LINEOUT** (**CHAROUT**), **ARRAYIN**, **ARRAYOUT**, **CLOSE**...

. columns 9 3 level=2

. click id=#p11x16

```rexx
tmpColl = .stream ~new("myinput.txt")~~open
SAY "a" tmpColl~class~id":"
DO i OVER tmpColl
    SAY "["i"]"
END
tmpColl~close
```



. next column

. click id=#p11x15

. file=myinput.txt:
```output
Max
und
Moritz
haben
...
```


. end columns

. after arrow #p11x15 -> #p11x16:1

. after label level=2
Output:

. after level=2
```output
a Stream:
[Max]
[und]
[Moritz]
[haben]
[...]
```

<!-- slide # 12 (2026-10-15 09:36) --------------------------- ODP slide # 12 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.2.4. Stream Class, 5.3.6. Array Class)" presenter="Till Winkler"
# Collection Classes – Ordered Collection

- **Stream** and **Array**
    . after
    - The stream method **ARRAYIN** reads the stream's content into an array such that array methods can be employed (e.g. **ITEMS**, **PUT**, **REMOVE**, **SORT**, ...)

. columns 9 3 level=2

. click group id=#p12x18

. after mark 2 "~ArrayIn" pen=1
```rexx
tmpColl = .stream ~new("myinput.txt")~~open
tmpArray = tmpColl~ArrayIn  -- read all lines into an array
tmpColl~close

SAY "a" tmpColl~class~id "becomes an" tmpArray~class~id","
SAY "the array has" tmpArray~items "items (lines):"
DO i OVER tmpArray
    SAY "["i"]"
END
```

. end group


. next column

. click group id=#p12x17

. mark id=#h2 1-5
. file=myinput.txt:
```output
Max
und
Moritz
haben
...
```

. after show #h2 pen=2

. with callout --> #p12x17:1-5 at=right
5 Items

. end group

. end columns

. after arrow #p12x17 -> #p12x18:2

. after label level=2
Output:

. after level=2
```output
a Stream becomes an Array,
the array has 5 items (lines):
[Max]
[und]
[Moritz]
[haben]
[...]
```

<!-- slide # 13 (2026-10-15 09:36) --------------------------- ODP slide # 13 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3. Collection Classes)"
# Collection Classes – Unordered Collection

. after steps
- Unordered collection classes
    . after
    - **Directory** - index (any string) associates one object only
    - **Relation** - index (any object) can associate multiple objects (**allAt**)
        - **Bag** - restriction: index and associated object are the same!
    - **Table** - index (any object) associates one object only
        - **Set** - restriction: index and associated object are the same!
    - (**Stem** - index (any string) associates one object only)
- There is no order in which the objects get collected
    . after
    - **DO...OVER** (also **SUPPLIER** objects) enumerate the collected objects (instances, values) in an arbitrary (unforeseeable) order!
        - Note: the loop variable in **DO...OVER** will supply the index with which an object is stored
            . after
            - One needs to use that index to fetch the object from the collection!

<!-- slide # 14 (2026-10-15 09:36) --------------------------- ODP slide # 14 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.9. Directory Class, 5.3.17. StringTable Class)"
# Collection Classes – Unordered Collection

- **Directory (StringTable)**
    . after
    - Directory objects allow the collecting of objects with a user defined index of type string

      . after
      . after mark 5-6 pen=1
      . after mark 7 "tmpColl~wu" pen=1
      . after mark 7 "tmpColl~rgf" pen=1
      ```rexx
      tmpColl = .directory ~new
      tmpColl["a_index"] = "a"
      tmpColl ~"[]="("b", "b_index")
      tmpColl ~~PUT("b", "b_index" ) ~~PUT("c", "c_index")
      tmpColl ~wu= "WU Wien"
      tmpColl ~rgf="Rony G. Flatscher"
      SAY "Acronym 'WU':" tmpColl~wu || ", 'RGF':" tmpColl~rgf
      SAY tmpColl~string":"
      DO i OVER tmpColl
               SAY "["i"]"
      END
      ```

      . click label
      Output:

      . after group id=#p14x19

      . with mark 1 "WU Wien," pen=2
      . with mark 1 "Rony G. Flatscher" pen=2
      . after mark 3-7 pen=2
      ```output
      Acronym 'WU': WU Wien, 'RGF': Rony G. Flatscher
      a Directory:
      [RGF]
      [c_index]
      [b_index]
      [a_index]
      [WU]
      ```

      . with callout --> #p14x19:3-7 at=right
      order could be different

      . end group

<!-- slide # 15 (2026-10-15 09:36) --------------------------- ODP slide # 15 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.14. Relation Class)"
# Collection Classes – Unordered Collection

- **Relation**
    . after
    - Relation objects allow the collecting of objects with a user defined index of any type (multiple objects per index possible)

      . after
      ```rexx
      tmpColl = .relation ~new
      tmpColl["a_index"] = "a"
      tmpColl ~"[]="("b", "b_index")
      tmpColl ~~PUT("b", "b_index" ) ~~PUT("c", "c_index")

      SAY tmpColl~string":"
      DO i OVER tmpColl
         SAY "["i"]"
      END
      ```

      . click label
      Output:

      . after group id=#p15x20

      . after mark 2-5 pen=1
      ```output
      a Relation:
      [c_index]
      [b_index]
      [b_index]
      [a_index]
      ```

      . with callout --> #p15x20:2-5 at=right
      order could be different

      . end group

<!-- slide # 16 (2026-10-15 09:36) --------------------------- ODP slide # 16 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.7. Bag Class)"
# Collection Classes – Unordered Collection

- **Bag**
    . after
    - Bag  objects allow the collecting of objects with a user defined index of any type (multiple objects per index possible, index and object are the same, hence index can be left out)

      . after
      ```rexx
      tmpColl = .bag ~new
      tmpColl["a"] = "a"
      tmpColl ~"[]="("b", "b")
      tmpColl ~~PUT("b") ~~PUT("c")

      SAY tmpColl~string":"
      DO i OVER tmpColl
         SAY "["i"]"
      END
      ```

      . click label
      Output:

      . after group id=#p16x21

      . after mark 2-5 pen=1
      ```output
      a Bag:
      [a]
      [b]
      [b]
      [c]
      ```

      . with callout --> #p16x21:2-5 at=right
      order could be different

      . end group

<!-- slide # 17 (2026-10-15 09:36) --------------------------- ODP slide # 17 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.18. Table Class)"
# Collection Classes – Unordered Collection

- **Table**
    . after
    - Table objects allow the collecting of objects with a user defined index of any type (one object per index)

      . after
      ```rexx
      tmpColl = .table ~new
      tmpColl["a_index"] = "a"
      tmpColl ~"[]="("b", "b_index")
      tmpColl ~~PUT("b", "b_index" ) ~~PUT("c", "c_index")

      SAY tmpColl~string":"
      DO i OVER tmpColl
         SAY "["i"]"
      END
      ```

      . click label
      Output:

      . after group id=#p17x22

      . after mark 2-4 pen=1
      ```output
      a Table:
      [c_index]
      [b_index]
      [a_index]
      ```

      . with callout --> #p17x22:2-4 at=right
      order could be different

      . end group

<!-- slide # 18 (2026-10-15 09:36) --------------------------- ODP slide # 18 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.15. Set Class)"
# Collection Classes – Unordered Collection

- **Set**
    . after
    - Set  objects allow the collecting of objects with a user defined index of any type (one object per index, index and object are the same, hence index can be left out)

      . after
      ```rexx
      tmpColl = .set ~new
      tmpColl["a"] = "a"
      tmpColl ~"[]="("b", "b")
      tmpColl ~~PUT("b") ~~PUT("c")

      SAY tmpColl~string":"
      DO i OVER tmpColl
         SAY "["i"]"
      END
      ```

      . click label
      Output:

      . after group id=#p18x23

      . after mark 2-4 pen=1
      ```output
      a Set:
      [a]
      [b]
      [c]
      ```

      . with callout --> #p18x23:2-4 at=right
      order could be different

      . end group

<!-- slide # 19 (2026-10-15 09:36) --------------------------- ODP slide # 19 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.16. Stem Class)"
# Collection Classes – Unordered Collection

- **Stem**
    . after
    - Stem objects allow the collecting of objects with a user defined index of type string (one object per index)

      . after
      ```rexx
      tmpColl = .stem ~new
      tmpColl["a_index"] = "a"
      tmpColl ~"[]="("b", "b_index")
      tmpColl ~~PUT("b", "b_index" ) ~~PUT("c", "c_index")

      SAY "a" tmpColl~class~id":"
      DO i OVER tmpColl
         SAY "["i"]"
      END
      ```

      . click label
      Output:

      . after group id=#p19x24

      . after mark 2-4 pen=1
      ```output
      a Stem:
      [a_index]
      [c_index]
      [b_index]
      ```

      . with callout --> #p19x24:2-4 at=right
      order could be different

      . end group

<!-- slide # 20 (2026-10-15 09:36) --------------------------- ODP slide # 20 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.16. Stem Class)" presenter="Till Winkler"
# Collection Classes – Excursion

- The **MAKEARRAY** method allows to transform any collection object into an **Array** object such that array methods can be employed (e.g. **ITEMS**, **PUT**, **REMOVE**, **SORT**, ...).

  . after
  . after mark 1 pen=1
  . after mark 6 pen=2
  ```rexx
  tmpColl = .stem ~new
  tmpColl["a_index"] = "a"
  tmpColl ~"[]="("b", "b_index")
  tmpColl ~~PUT("b", "b_index" ) ~~PUT("c", "c_index")

  tmpArray = tmpColl~makeArray

  SAY "a" tmpArray~class~id":"
  DO i OVER tmpArray
     SAY "["i"]"
  END
  ```

  . click label
  Output:

  . after
  . after mark 1 pen=3
  ```output
  a Array:
  [a_index]
  [c_index]
  [b_index]
  ```

<!-- slide # 21 (2026-10-15 09:36) --------------------------- ODP slide # 21 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.16. Stem Class)" presenter="Till Winkler"
# Collection Classes – Excursion

- All collection classes have a **MAKEARRAY** method that allows to transform any collection object into an **Array** object such that array methods can be employed (e.g. **ITEMS**, **PUT**, **REMOVE**, **SORT**, ...).

. columns 8 4 level=1

. click group id=#p21x25

. after mark 1 pen=1
. after mark 3 pen=1
. after mark 10 pen=2
```rexx
tmpColl = .list~of("orange", "banana", "apple")

tmpArray = tmpColl~makeArray  -- turn collection into array
say "there are" tmpArray~items "items in the array (list)"
SAY "an" tmpArray~class~id":"
DO i OVER tmpArray
   SAY "["i"]"
END
say "... and in sorted order:"
DO i OVER tmpArray~sort       -- sort array
   SAY "["i"]"
END
```

. end group


. next column

. click label
Output:

. after id=#p21x26

```output
there are 3 items in the array (list)
an Array:
[orange]
[banana]
[apple]
... and in sorted order:
[apple]
[banana]
[orange]
```


. end columns

. after arrow #p21x25:5 -> #p21x26:2

. after arrow #p21x25:9 -> #p21x26:6

<!-- slide # 22 (2026-10-15 09:36) --------------------------- ODP slide # 22 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.11. List Class, 5.2.4. Stream Class, 5.3.6. Array Class)" presenter="Till Winkler"
# Collection Classes – Excursion

- **List, Array** and **Stream**
    . after
    - By default, the **OPEN** stream method opens the stream for reading and writing data
        . after
        - The read pointer is set to the first byte, the write pointer to the end of the file, such that writing to the file effectively appends it
        . click
        - Using the **OPEN** option `"replace"` causes the file's old content to be deleted
    . click
    - The stream method **ARRAYOUT** writes collected objects into a file.

. columns 9 3 level=1

. after group id=#p22x27

. click mark 1 pen=1
. after mark 5 '"replace"' pen=1
. after mark 6 pen=1
```rexx
tmpColl = .list~of("orange", "banana", "apple")

tmpArray = tmpColl~makeArray~sort   -- make & sort array

tmpStream = .Stream~new("myoutput.txt")~~open("replace")
tmpStream~ArrayOut(tmpArray)
tmpStream~close
```

. end group


. next column

. after id=#p22x28

. file=myoutput.txt:
```output
apple
banana
orange
```


. end columns

. after arrow #p22x27 -> #p22x28

<!-- slide # 23 (2026-10-15 09:36) --------------------------- ODP slide # 23 -->
. slide kicker="Classification Tree (ooRexx 3.1)" reference="Cf. rexxref.pdf (5. Builtin Classes)"
# Iterator Class

. mark id=#t1 "Supplier"
. tree layout=columns flow=4
- Object
  - Class
  - Method
  - Message
  - Alarm
  - Monitor
  . break
  - String
  - Stem
  - Stream
  - MutableBuffer
  . break
  - Array
  - List
  - Queue
    . under
    - CircularQueue
  - Supplier
  . break
  - Directory
  - Relation
    - Bag
  - Table
    - Set

. after show #t1

<!-- slide # 24 (2026-10-15 09:36) --------------------------- ODP slide # 24 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.4.21. Supplier Class)"
# Iterator Class, 1

. steps
. static
- **Supplier**
    . after
    - Supplier objects allow enumerating all objects contained in a collection
        - A supplier object presents each collected object together with its index
        - As the index-object pair is returned by the supplier object, there is no need to know whether the underlying collection is one where the index is user defined or not
    - All builtin collection classes possess a method **SUPPLIER** which returns a snapshot of the collection and returns it in the form of a **SUPPLIER** object

      . after
      ```rexx
      tmpSupp = tmpColl~SUPPLIER
      DO WHILE tmpSupp~AVAILABLE
         SAY "index ["tmpSupp~INDEX"] item ["tmpSupp~ITEM"]"
         tmpSupp~NEXT
      END
      ```

    - "Blueprint" code for enumerating all collected objects of a collection using the methods of its **SUPPLIER** object

<!-- slide # 25 (2026-10-15 09:36) --------------------------- ODP slide # 25 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (2.4. DO, 5.4.21. Supplier Class)"
# Iterator Class, 2

- **Supplier**
    - [ooRexx 5 introduces the ability to loop over a collection object directly \
      ("**DO WITH … OVER ...**") assigning the index value and the item value to the defined loop variables in each iteration]{.fragment .afterPrevious}
    . click
    - "Blueprint" code for enumerating all collected objects (using implicitly the collection's **SUPPLIER** object)

      . with
      ```rexx
      DO WITH INDEX idx ITEM obj OVER tmpColl
         SAY "index ["idx"] item ["obj"]"
      END
      ```

        . after
        - Note: this form of the **DO** instruction will send the  *tmpColl* collection the message *supplier* and process the resulting **SUPPLIER** object

<!-- slide # 26 (2026-10-15 09:36) --------------------------- ODP slide # 26 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (2.4. DO, 5.4.21. Supplier Class, 5.3.14. Relation Class)"
# Iterator Class, 3

- **Relation** (unordered collection)

. columns 6 6

```rexx
tmpColl = .relation ~new
tmpColl["a_index"] = "a"
tmpColl ~"[]="("b", "b_index")
tmpColl ~~PUT("b", "b_index" ) ~~PUT("c", "c_index")

SAY tmpColl~string":"

tmpSupp = tmpColl~SUPPLIER
DO WHILE tmpSupp~AVAILABLE
   SAY "index ["tmpSupp~INDEX"] item ["tmpSupp~ITEM"]"     tmpSupp~NEXT
END
```


. next column

. click
```rexx
tmpColl = .relation ~new
tmpColl["a_index"] = "a"
tmpColl ~"[]="("b", "b_index")
tmpColl ~~PUT("b", "b_index" ) ~~PUT("c", "c_index")

SAY tmpColl~string":"


DO WITH INDEX idx ITEM obj OVER tmpColl
   SAY "index ["idx"] item ["obj"]"
END
```

. end columns

. click label
Output:

. after group id=#p26x29

. after mark 2-5 pen=1
```output
a Relation:
index [c_index] item [c]
index [b_index] item [b]
index [b_index] item [b]
index [a_index] item [a]
```

. with callout --> #p26x29:2-5 at=right
order could be different

. end group

<!-- slide # 27 (2026-10-15 09:36) --------------------------- ODP slide # 27 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (2.4. DO, 5.4.21. Supplier Class, 5.3.6. Array Class)"
# Iterator Class, 4

- **2-dimensional Array** (ordered collection)

. columns 7 5

. after mark 11 pen=1
```rexx
tmpColl = .array ~new
tmpColl[2,3] = "a"
tmpColl ~"[]="("b", 1, 1)
tmpColl ~~put("b", 4, 5) ~~put("c", 1, 2)

SAY tmpColl~string":"

tmpSupp = tmpColl~SUPPLIER
DO WHILE tmpSupp~AVAILABLE
   idx = tmpSupp~INDEX
   SAY "index ["idx~makeString("L",",")"] item ["tmpSupp~ITEM"]"
   tmpSupp~NEXT
END
```


. next column

. click
```rexx
tmpColl = .array ~new
tmpColl[2,3] = "a"
tmpColl ~"[]="("b", 1, 1)
tmpColl ~~put("b", 4, 5) ~~put("c", 1, 2)

SAY tmpColl~string":"



DO WITH INDEX idx ITEM obj OVER tmpColl
   SAY "index ["idx~toString("L",",")"] item ["obj"]"
END
```

. end columns

. click label
Output:

. after group id=#p27x30

. after mark 2-5 pen=2
```output
an Array:
index [1,1] item [b]
index [1,2] item [c]
index [2,3] item [a]
index [4,5] item [b]
```

. with callout --> #p27x30:2-5 at=right
order will be always the same!

. end group

<!-- slide # 28 (2026-10-15 09:36) --------------------------- ODP slide # 28 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (2.4. DO, 5.4.21. Supplier Class, 5.3.15. Set Class)"
# Iterator Class, 5

- **Set** (unordered collection)

. columns 6 6

```rexx
tmpColl = .set ~new
tmpColl["a"] = "a"
tmpColl ~"[]="("b", "b")
tmpColl ~~PUT("b") ~~PUT("c")

SAY tmpColl~string":"

tmpSupp = tmpColl~SUPPLIER
DO WHILE tmpSupp~AVAILABLE
   SAY "index ["tmpSupp~INDEX"] item ["tmpSupp~ITEM"]"
   tmpSupp~NEXT
END
```


. next column

. click
```rexx
tmpColl = .set ~new
tmpColl["a"] = "a"
tmpColl ~"[]="("b", "b")
tmpColl ~~PUT("b") ~~PUT("c")

SAY tmpColl~string":"


DO WITH INDEX idx ITEM obj OVER tmpColl
   SAY "index ["idx"] item ["obj"]"
END
```

. end columns

. click label
Output:

. after group id=#p28x31

. after mark 2-4 pen=1
```output
a Set:
index [a] item [a]
index [b] item [b]
index [c] item [c]
```

. with callout --> #p28x31:2-4 at=right
order could be different

. end group

<!-- slide # 29 (2026-10-15 09:36) --------------------------- ODP slide # 29 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.2. Collection Class)"
# Setlike Operations

. after
- *Union* of two collections
    - Result includes all items from both, the receiver and the argument collection
. click
- *Intersection* of two collections
    - Result includes all items of the receiver collection that are also in the argument collection
. click
- *XOR* of two collections (exclusive or)
    - Result includes all items that are contained only in the receiver, but not in the argument collection and vice versa
. click
- *Difference* (remove items from receiver collection)
    - Result removes all items from the receiver collection that are in the argument collection
. click
- *Subset*
    - Returns *.true*, if the receiver collection is a subset of the argument collection

<!-- slide # 30 (2026-10-15 09:36) --------------------------- ODP slide # 30 -->
. slide kicker="Classification Tree (ooRexx 3.1)" reference="Cf. rexxref.pdf (5. Builtin Classes, 5.3.2. Collection Class)"
# Collection Classes: Union, Intersection, XOR, Difference, Subset

. with
- with **Union**, **Intersection**, **XOR**, **Difference**, **Subset**

. mark id=#t1 "Array" "List" "Queue" "CircularQueue" "Directory" "Relation" "Bag" "Table" "Set"
. mark id=#t2 "Stem" "Stream"
. tree layout=columns flow=4
- Object
  - Class
  - Method
  - Message
  - Alarm
  - Monitor
  . break
  - String
  - Stem
  - Stream
  - MutableBuffer
  . break
  - Array
  - List
  - Queue
    . under
    - CircularQueue
  - Supplier
  . break
  - Directory
  - Relation
    - Bag
  - Table
    - Set

. show #t1 hull

. after show #t2 hull anim=fade

<!-- slide # 31 (2026-10-15 09:36) --------------------------- ODP slide # 31 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.7. Bag Class)"
# Collection Classes: Union, Intersection, XOR, Difference, Subset, 1

- Two **Bag** collections

  . after mark 1-2 pen=1
  ```rexx
  coll_1 = .bag ~of("a", "b", "b")
  coll_2 = .bag ~of(     "b", "b", "c")
  CALL dump coll_1~UNION(coll_2),        "UNION       "
  CALL dump coll_1~INTERSECTION(coll_2), "INTERSECTION"
  CALL dump coll_1~XOR(coll_2),          "XOR         "
  CALL dump coll_1~DIFFERENCE(coll_2),   "DIFFERENCE  "
  SAY coll_1~SUBSET(coll_1) "-" coll_1~SUBSET(coll_2)

  ::ROUTINE dump
    USE ARG tmpColl, title
    .output~CHAROUT( title tmpColl~string": ")
    DO i OVER tmpColl
       .output~CHAROUT("["i"] ")
    END
    .output~say
  ```

  . click label
  Output:

  . after group id=#p31x32

  . after mark 1-4 pen=2
  ```output
  UNION        a Bag: [a] [b] [b] [b] [b] [c]
  INTERSECTION a Bag: [b] [b]
  XOR          a Bag: [a] [c]
  DIFFERENCE   a Bag: [a]
  1 - 0
  ```

  . with callout --> #p31x32:1-4 at=right
  order could be different

  . end group

<!-- slide # 32 (2026-10-15 09:36) --------------------------- ODP slide # 32 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.15. Set Class, 5.3.7. Bag Class)"
# Collection Classes: Union, Intersection, XOR, Difference, Subset, 2

- A **Set** and a **Bag** collection

  . after mark 1-2 pen=1
  ```rexx
  coll_1 = .set ~of("a", "b", "b")
  coll_2 = .bag ~of(     "b", "b", "c")
  CALL dump coll_1~UNION(coll_2),        "UNION       "
  CALL dump coll_1~INTERSECTION(coll_2), "INTERSECTION"
  CALL dump coll_1~XOR(coll_2),          "XOR         "
  CALL dump coll_1~DIFFERENCE(coll_2),   "DIFFERENCE  "
  SAY coll_1~SUBSET(coll_1) "-" coll_1~SUBSET(coll_2)

  ::ROUTINE dump
    USE ARG tmpColl, title
    .output~CHAROUT( title tmpColl~string": ")
    DO i OVER tmpColl
       .output~CHAROUT("["i"] ")
    END
    .output~say
  ```

  . click label
  Output:

  . after group id=#p32x33

  . after mark 1-4 pen=2
  ```output
  UNION        a Set: [a] [b] [c]
  INTERSECTION a Set: [b]
  XOR          a Set: [a] [c]
  DIFFERENCE   a Set: [a]
  1 - 0
  ```

  . with callout --> #p32x33:1-4 at=right
  order could be different

  . end group

<!-- slide # 33 (2026-10-15 09:36) --------------------------- ODP slide # 33 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.15. Set Class, 5.3.7. Bag Class)"
# Collection Classes: Union, Intersection, XOR, Difference, Subset, 3

- A **Bag** and a **Set** collection

  . after mark 1-2 pen=1
  ```rexx
  coll_1 = .bag ~of("a", "b", "b")
  coll_2 = .set ~of(     "b", "b", "c")
  CALL dump coll_1~UNION(coll_2),        "UNION       "
  CALL dump coll_1~INTERSECTION(coll_2), "INTERSECTION"
  CALL dump coll_1~XOR(coll_2),          "XOR         "
  CALL dump coll_1~DIFFERENCE(coll_2),   "DIFFERENCE  "
  SAY coll_1~SUBSET(coll_1) "-" coll_1~SUBSET(coll_2)

  ::ROUTINE dump
    USE ARG tmpColl, title
    .output~CHAROUT( title tmpColl~string": ")
    DO i OVER tmpColl
       .output~CHAROUT("["i"] ")
    END
    .output~say
  ```

  . click label
  Output:

  . after group id=#p33x34

  . after mark 1-4 pen=2
  ```output
  UNION        a Bag: [a] [b] [b] [b] [c]
  INTERSECTION a Bag: [b]
  XOR          a Bag: [a] [b] [c]
  DIFFERENCE   a Bag: [a] [b]
  1 - 0
  ```

  . with callout --> #p33x34:1-4 at=right
  order could be different

  . end group

<!-- slide # 34 (2026-10-15 09:36) --------------------------- ODP slide # 34 -->
. slide kicker="Classification Tree" reference="Cf. rexxref.pdf (5.3.2. Collection Class)"
# Collection Classes: Union, Intersection, XOR, Difference, Subset, 4

- Result is always an object of the same type as the receiving collection object
    . click
    - Argument of a setlike message can be any collection object
    . click
    - Argument will be first converted to the type of the receiving collection before carrying out the operation
        . click
        - If the argument collection object has no user defined index (i.e., the ordered collections **Array**, **List**, **Queue**, **Stem**, **Stream**) then the collection is turned into a **Bag** collection containing the collected objects

<!-- slide # 35 (2026-10-15 09:36) ----------- business card (not in the ODP) -->
. slide card logo=none
# Contact