5.3.20.4. Determining the Identity of an Item
Set operations require the definition of the identity of an element to
determine whether a certain element exists in the receiver collection.
The element of a collection is conceived as
the tuple (
index, item).
The
index is used as the identification
tag associated with the item.
Depending on the collection class, the index is an instance of a particular
class, for example, the string class for a directory element, an integer for
an array, or any arbitrary class for a relation. The Array class is an exception
because it can be multi-dimensional having more than one index. However, as
a collection, it is conceptionally linearized by the set operator.
For collection classes that require unique indexes, namely
the Set, IdentityTable, Table, Directory, and Stem, an item is identified by its
index. For collections of collection classes
that allow several items to have the same index, namely the Relation class,
an item is identified by both its
index
and its
item. For the Bag and the Set
subclasses, where several items can have the same index but
index and
item must
be identical, the item is identified by its
index.
For Array, List, and Queue classes, the index is derived from an object's position
within the collection's order. Items are identified using only
item.
When collections with different index semantics are used in set operations,
the argument collection is coerced into a collection of the same type as the receiver,
and the operation is then performed using the converted collection. The coercion process
differs based on the types of both the receiver and the argument collection.
According to this
concept, an item of a collection is identified for the different
receiver
categories as follows: