de.rwth.domains
Interface Set

All Known Subinterfaces:
CompleteLattice, CompletePOSet, Lattice, LowerSemiLattice, POSet, PreLattice, PreLowerSemiLattice, PreUpperSemiLattice, UpperSemiLattice
All Known Implementing Classes:
FunctionSet, SumSet, SimpleSet, TupleSet, StackSet, NumberSet

public interface Set

Interface for modeling mathematical sets. A set knows all its elements, the number of elements, and can be used to iterate over them.

This is not intended to be used for implementing collection data structures:

  1. After creation, sets do not change: No elements are added or removes
  2. Sets can be infinite: In this case, the size() must return -1. For debugging purposes, a (finite) skeleton subset may be defined using sizeSkel() and iteratorSkel().
Since iterator() and isElement() are closely related, there is an inner class Default containing a default implementation of isElement() in terms of iterator().

Version:
$Id: Set.java,v 1.2 2002/09/17 06:53:53 mohnen Exp $
Author:
Markus Mohnen

Inner Class Summary
static class Set.Default
          Container class for default implementations of methods.
 
Method Summary
 boolean equals(java.lang.Object e1, java.lang.Object e2)
          Checks if two elements of this set are equal.
 boolean isElement(java.lang.Object e)
          Checks if an element is contained in this set.
 java.util.Iterator iterator()
          Returns an Iterator of the elements of this set.
 java.util.Iterator iteratorSkel()
          Returns an Iterator of the elements of the skeleton subset this set.
 long size()
          Returns the size of this set.
 long sizeSkel()
          Returns the size of the skeleton subset of this set.
 

Method Detail

equals

public boolean equals(java.lang.Object e1,
                      java.lang.Object e2)
Checks if two elements of this set are equal.
Implementations should guarantee that equals is reflexive, transitive and symmetric. Furthermore, equals(e1,e2) should coincide with e1.equals(e2).
Parameters:
e1 - a value of type Object
e2 - a value of type Object
Returns:
true if e1 and e2 belong to this set and are equal, false otherwise
See Also:
Domain.checkProperties(Set set)

isElement

public boolean isElement(java.lang.Object e)
Checks if an element is contained in this set.
Implementations should guarantee that isElement() is true for all objects generated by iterator() and false for all other objects.
Parameters:
e - a value of type Object
Returns:
true if and only if this set contains this element.
See Also:
iterator(), Domain.checkProperties(Set set)

iterator

public java.util.Iterator iterator()
Returns an Iterator of the elements of this set.
Implementations should guarantee that:
Returns:
an Iterator of all elements of this set.
See Also:
isElement(Object e), Domain.checkProperties(Set set)

size

public long size()
Returns the size of this set.
Implementations should guarantee that it is the number of times iterator().hasNext() can be called.
Returns:
-1 iff the set has infinite size, the number of elements otherwise.
See Also:
Domain.checkProperties(Set set)

iteratorSkel

public java.util.Iterator iteratorSkel()
Returns an Iterator of the elements of the skeleton subset this set. It maybe null if there is no skeleton subset.
Implementations should guarantee that:
Returns:
an Iterator of all elements of this set.
See Also:
isElement(Object e), Domain.checkProperties(Set set)

sizeSkel

public long sizeSkel()
Returns the size of the skeleton subset of this set.
Implementations should guarantee that it is the number of times iterator().hasNext() can be called.
Returns:
-1 iff there is no skeleton subset, the number of elements otherwise.
See Also:
Domain.checkProperties(Set set)