Properties and Operators

Java collection classes have been provided with a fairly rich set of properties and operators, presumably based on the idea that these classes can then be used for a richer range of rôles, just as there are many classes in that same hierarchy which are clearly not intended for relationships at all. In the present implementation, the decision was made to focus on the essentials of object relationships with the idea of creating efficient, low impact infrastructure for OO programming and then to consider later whether there are other classes with other functions which could also be created. Therefore, this implementation uses minimal properties and operators.

Note that we are using a leading "a" to indicate an abstract class and a leading "i" to indicate an interface.

aSet
This is the abstract class for the most common collection type, that ordered only by the sequence in which elements are added to it. It has two read-only properties – Size (number of elements) and IsEmpty. It has and four operators:

  • Add – adds the object in its parameter to the collection;
  • Remove – removes the object in its parameter from the collection;
  • Clear – removes all elements from the collection;
  • Contains – returns a logical indicating whether the object parameter is in the collection; and
  • Get Iterator - returns an Iterator object on the class.
    Note that Contains will be inefficient on a large aSet and aIDSet is preferred if this is a regular need.

aIDSet
This is the abstract class for the simple collection type ordered by object identity. It has all of the same properties and operators as aSet plus one additional operator Get which has an integer argument and which returns the object with that identity.

aAttrKeySet
This is the abstract class which takes key/value pairs in which the key is considered an identifier for the object, i.e., keys must be unique. It has the same two properties as aSet. Its operators are:

  • Add – parameters are a key/value pair which is added to the collection;
  • GetValue – returns the object corresponding to the key in the parameter;
  • RemoveKey – removes the key/value entry specified by the key in the parameter;
  • RemoveValue – removes the key/value entry corresponding to the object in the parameter;
  • Clear – removes all entries
  • Contains – returns a logical indicating whether the object parameter is in the collection; and
  • GetIterator – returns an Iterator on the keys.

aAttrSortSet
This is the abstract class which takes key/value pairs, but the key is considered only an attribute which defines sort order, not a unique key. It has the same properties and operators as aAttrKeySet except that GetValue is replaced by GetValues which return a collection of all objects in the collection with the key in the parameter.

iIterator
This is the interface which defines the signature for all collection iterators. It has two read-only properties – HasNext and HasPrev. Its operators are:

  • First – positions at the first object in the collection and returns it;
  • Next – advances to the next object in the collection and returns it;
  • Last – positions at the last object in the collection and returns it;
  • Prev – advances in reverse order to the previous object in the collection and returns it; and
  • Remove – removes the object at the current position from the collection.

Note that we have considered whether the key/value collection classes should have both GetAttrIterator, i.e., on the keys, and GetIDIterator, i.e., on the ID of the objects, as this would be easy to do with a temp-table implementation. Currently, we are leaning toward just GetIterator on the keys as this seems in keeping with the needs of relationships.