kodkod.util.ints
Class AbstractIntSet

java.lang.Object
  extended by kodkod.util.ints.AbstractIntCollection
      extended by kodkod.util.ints.AbstractIntSet
All Implemented Interfaces:
java.lang.Cloneable, IntCollection, IntSet
Direct Known Subclasses:
ArrayIntSet, IntBitSet, IntTreeSet

public abstract class AbstractIntSet
extends AbstractIntCollection
implements IntSet

A skeletal implementation of the IntSet interface.

Author:
Emina Torlak

Method Summary
 IntSet clone()
          Returns the result of calling super.clone().
 boolean equals(java.lang.Object o)
          Compares the specified object with this set for equality.
 int hashCode()
          Returns the hash code value for this set.
 IntIterator iterator()
          Returns an ascending iterator over all elements in this set.
 int max()
          Returns the first element returned by this.iterator(Integer.MAX_VALUE, Integer.MIN_VALUE).
 int min()
          Returns the first element returned by this.iterator().
 java.lang.String toString()
          Returns a string representation of this int set.
 
Methods inherited from class kodkod.util.ints.AbstractIntCollection
add, addAll, clear, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface kodkod.util.ints.IntSet
add, addAll, ceil, clear, contains, containsAll, floor, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

iterator

public IntIterator iterator()
Returns an ascending iterator over all elements in this set. This method calls this.iterator(Integer.MIN_VALUE, Integer.MAX_VALUE).

Specified by:
iterator in interface IntCollection
Specified by:
iterator in interface IntSet
Returns:
an ascending iterator over all elements in this set.

min

public int min()
Returns the first element returned by this.iterator(). If this set is empty, throws a NoSuchElementException().

Specified by:
min in interface IntSet
Returns:
min(this.ints)
Throws:
java.util.NoSuchElementException - - no this.ints

max

public int max()
Returns the first element returned by this.iterator(Integer.MAX_VALUE, Integer.MIN_VALUE). If this set is empty, throws a NoSuchElementException().

Specified by:
max in interface IntSet
Returns:
max(this.ints)
Throws:
java.util.NoSuchElementException - - no this.ints

clone

public IntSet clone()
             throws java.lang.CloneNotSupportedException
Returns the result of calling super.clone().

Specified by:
clone in interface IntSet
Overrides:
clone in class java.lang.Object
Returns:
the result of calling super.clone()
Throws:
java.lang.CloneNotSupportedException - - this is not cloneable
See Also:
Object.clone()

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this set for equality. Returns true if the specified object is also an IntSet, the two sets have the same size, and every member of the specified set is contained in this set (or equivalently, every member of this set is contained in the specified set). This definition ensures that the equals method works properly across different implementations of the IntSet interface.

Specified by:
equals in interface IntSet
Overrides:
equals in class java.lang.Object
Returns:
o instanceof IntSet and o.size() = this.size() and this.containsAll(o)

hashCode

public int hashCode()
Returns the hash code value for this set. The hash code of a set is defined to be the Ints.superFastHash(int[]) of the elements in the set, taken in the ascending order of values. This ensures that s1.equals(s2) implies that s1.hashCode()==s2.hashCode() for any two IntSets s1 and s2, as required by the general contract of the Object.hashCode method.

Specified by:
hashCode in interface IntSet
Overrides:
hashCode in class java.lang.Object
Returns:
Ints.superFastHash(this.toArray())

toString

public java.lang.String toString()
Returns a string representation of this int set.

Overrides:
toString in class java.lang.Object
Returns:
a string representation of this int set.