Next: Reference Counting Up: Discussion Previous: Discussion

### Organization

Class Collection itself is an abstract base class, meaning that there are no true ``Collection'' objects. However, pointers and references to sets and sequences of the Collection hierarchy have access to a consistent interface, consisting of a set of member function prototypes and a set of comparison operations. The term collection objects is used to refer to instances of classes in the hierarchy. The elements stored in collection objects are considered to come from a totally ordered universe. In order to compile an instantiation of a collection object with a new element type A, the following operations must be defined:

- `A::int operator==(const A&) const;`
- `A::int operator<(const A&) const;`
- `friend ostream& operator<<(ostream&, const A&);`

The collection objects available to the programmer are listed below and defined completely in the subsections to follow.

- `MSetBase<Item, Impl>` : Multiset (the implementation can be chosen by the programmer).
- `SetBase<Item, Impl>` : Set (the implementation can be chosen by the programmer).
- `SequenceBase<Item, Impl>` : Sequence (the implementation can be chosen by the programmer).
- `MSet<Iteml>`: Multiset which uses the DEFAULT_SET_IMPL defined in MSet.h.
- `Set<Iteml>`: Multiset which uses the DEFAULT_SET_IMPL defined in MSet.h.
- `Set<Iteml>`: Multiset which uses the DEFAULT_SEQ_IMPL defined in Sequence.h.

The comparison methods of set objects (MSetBase, MSet, SetBase, Set) work under the assumption that the elements are stored in lexicographic order. Therefore, in order for these operations to work correctly, the underlying Container implementation must store the elements in sorted order, or at least be capable of iterating through the elements in sorted order. With this restriction in mind, it is possible to introduce new Container objects into LINK and use them as Collection implementations.

Next: Reference Counting Up: Discussion Previous: Discussion