University of Sheffield   

    The Simons
    Component Library

Introduction   Class Hierarchy   Class Listing   Index of Classes   Index of Methods   Header Files  

Unordered Class Reference

#include <Unordered.h>

Inheritance diagram for Unordered:

Collection Object Bag Set Relation Map List of all members.

Detailed Description

Unordered: the abstract superclass of all unordered collections.

The Unordered class is an intermediate class in the collections hierarchy and the superclass of all unordered collections, such as Set, Bag and Map. In an Unordered collection, the inserted order of elements is not significant. Adding new elements includes them anywhere in the Unordered collection. The notions of element membership and a count of the number of occurrences are meaningful. Elements may be visited in an arbitrary order via an index in the range 0..n-1, where n is the size of the Unordered collection. Unordered defines the interface for seeking and counting specific elements. Unordered defines the interface for adding, removing and retaining single elements and collections of elements. Comparing two Unordered collections performs a symmetric test for inclusion. Hashing on an Unordered collection is sensitive only to the values, but not the order, of the elements.


Public Member Functions

 Unordered ()
 Construct an empty Unordered collection.

virtual ~Unordered ()
 Destroy and release an Unordered collection.

virtual Natural hash () const
 Return a quasi-unique hash code for this Unordered collection.

virtual Order compare (ObjectID) const
 Compare this Unordered collection with another Object.

Order compare (UnorderedID) const
 Compare this Unordered collection with another Unordered collection.

virtual Natural count (ObjectID) const
 Count the occurrences of an Object in this Unordered collection.

virtual ObjectID find (ObjectID) const
 Find one or more Objects equal to another in this Unordered collection.

virtual Void remove (ObjectID)
 Remove an Object from this Unordered collection.

Void removeAll (CollectionID)
 Remove all the elements present in another Collection.

virtual Void retainAll (CollectionID)
 Retain only the elements present in another Collection.


Protected Member Functions

Natural nextCapacity (Natural) const
 Return the next hash table capacity.

 Unordered (const Unordered &)
 Copy another Unordered collection.


Constructor & Destructor Documentation

Unordered::Unordered const Unordered &  other  )  [protected]
 

Copy another Unordered collection.

Required by C++ to ensure that copying an Unordered collection faithfully copies a Collection.

Parameters:
other - the other Unordered collection to copy.

Unordered::Unordered  ) 
 

Construct an empty Unordered collection.

Returns:
an empty Unordered collection.

Unordered::~Unordered  )  [virtual]
 

Destroy and release an Unordered collection.


Member Function Documentation

Order Unordered::compare UnorderedID  other  )  const
 

Compare this Unordered collection with another Unordered collection.

A symmetric comparison which tests for the mutual containment of one Unordered collection in the other. Returns an Order in which LESS means contained within, EQUAL means has the identical quantity of each element, MORE means contains, NONE means incomparable and disjoint and SOME means incomparable, but overlapping.

Parameters:
other - the other Unordered collection.
Returns:
an Order in: { NONE, LESS, EQUAL, MORE, SOME }

Order Unordered::compare ObjectID  object  )  const [virtual]
 

Compare this Unordered collection with another Object.

Generic comparison that tries to convert the other Object into an Unordered collection then proceeds to compare according to mutual containment of elements. If the other Object is not an Unordered collection, the comparison is undefined and the result is NONE.

Parameters:
object - another Object.
Returns:
an Order in: { NONE, LESS, EQUAL, MORE, SOME }

Reimplemented from Object.

Natural Unordered::count ObjectID  object  )  const [virtual]
 

Count the occurrences of an Object in this Unordered collection.

This method is abstract, since different types of Unordered collection access their elements in different ways.

Parameters:
object - an Object to search for.
Returns:
the number of times the Object was found.

Reimplemented in Bag, and Set.

ObjectID Unordered::find ObjectID  object  )  const [virtual]
 

Find one or more Objects equal to another in this Unordered collection.

This method is abstract, since different types of Unordered collection access their elements in different ways. In Set and its descendants, this returns a unique Object, or null. In Bag and its descendants, this returns a Bag of Objects judged EQUAL under compare(), or null.

Parameters:
object - the Object to search for.
Returns:
one or more Objects judged EQUAL in this Unordered collection, or null.

Reimplemented in Bag, and Set.

Natural Unordered::hash  )  const [virtual]
 

Return a quasi-unique hash code for this Unordered collection.

Sums the hash codes of the individual elements, modulo the maximum Natural number. The result is only based on the values of elements. Unordered collections that contain the same elements (in any order) will always yield identical hash codes.

Returns:
a quasi-unique hash code.

Reimplemented from Object.

Natural Unordered::nextCapacity Natural  previous  )  const [protected]
 

Return the next hash table capacity.

Calculates the next greater hash table capacity than the previous capacity (or than zero, initially). Each capacity is guaranteed to be a prime number and is approximately double the previous capacity. The least capacity returned is 13 and the greatest capacity, after 26 doublings, is 1073741789. Any attempt to grow larger than this requires unrepresentable numbers and raises an OutOfRange exception. This method is used in the prediction of hash table sizes during the construction and resizing of all Unordered collections.

Parameters:
previous - the previous capacity
Returns:
a Natural table capacity

Void Unordered::remove ObjectID  object  )  [virtual]
 

Remove an Object from this Unordered collection.

This method is abstract, since different types of Unordered collection access their elements in different ways.

Parameters:
object - an Object

Reimplemented in Bag, Map, Relation, and Set.

Void Unordered::removeAll CollectionID  other  ) 
 

Remove all the elements present in another Collection.

This is equivalent to mutating set subtraction, bag subtraction, or domain anti-restriction, depending on the semantics of remove(). Iterates over the Collection using item() and uses remove() to remove each element from this Unordered collection.

Parameters:
other - another Collection.

Void Unordered::retainAll CollectionID  other  )  [virtual]
 

Retain only the elements present in another Collection.

This is equivalent to mutating set intersection, bag intersection or domain restriction, depending on the semantics of remove(). The default implementation copies this Unordered collection into a mask, removes all the elements of the other Collection from the mask, then removes all the elements of the mask from this Unordered collection. The double subtraction method is necessary to retain the correct quantities of elements.

Parameters:
other - another Collection.

Reimplemented in Map, and Relation.


The documentation for this class was generated from the following files:
Generated on Fri May 5 17:17:20 2006 for The Simons Component Library by doxygen1.3