edu.emory.mathcs.util.collections.ints
Class AbstractIntSet

java.lang.Object
  extended byedu.emory.mathcs.util.collections.ints.AbstractIntCollection
      extended byedu.emory.mathcs.util.collections.ints.AbstractIntSet
All Implemented Interfaces:
IntCollection, IntSet
Direct Known Subclasses:
AbstractIntSortedSet, IntRadkeHashSet

public abstract class AbstractIntSet
extends AbstractIntCollection
implements IntSet

Convenience subclass for int sets.

Version:
1.0
Author:
Dawid Kurzyniec

Constructor Summary
protected AbstractIntSet()
           
 
Method Summary
 boolean addAll(IntCollection c)
          Adds all of the elements in the specified collection to this set if they're not already present, and if they fall within this set's domain.
 boolean addInterval(int first, int last)
          Adds to this set all the numbers between first and last, inclusive, that are not already present in this set and beint to this set's domain.
 IntSet complementSet()
          Returns a complement view of this set.
 boolean containsInterval(int first, int last)
          Returns true if this set contains all the numbers between first and last, inclusive; false otherwise.
 boolean equals(java.lang.Object obj)
          Two sets are equal if they consists of the same elements.
 int hashCode()
           
 boolean isEmpty()
          Returns true if this set is empty; false otherwise.
 int max()
          The largest number that can be stored in this set.
 int min()
          The smallest number that can be stored in this set.
 boolean removeAll(IntCollection c)
          Removes from this set all of its elements that are contained in the specified collection.
 boolean removeInterval(int first, int last)
          Removes from this set all the numbers between first and last, inclusive.
 boolean retainAll(IntCollection c)
          Retains only the elements in this set that are contained in the specified collection.
 boolean retainInterval(int first, int last)
          Retains in this set only the numbers between first and last, inclusive.
 
Methods inherited from class edu.emory.mathcs.util.collections.ints.AbstractIntCollection
add, clear, contains, containsAll, iterator, remove, size, size64, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.emory.mathcs.util.collections.ints.IntSet
add, clear, contains, containsAll, iterator, remove, size, size64, toArray, toArray
 

Constructor Detail

AbstractIntSet

protected AbstractIntSet()
Method Detail

min

public int min()
Description copied from interface: IntSet
The smallest number that can be stored in this set.

Specified by:
min in interface IntSet
Returns:
the smallest number that can be stored in this set

max

public int max()
Description copied from interface: IntSet
The largest number that can be stored in this set.

Specified by:
max in interface IntSet
Returns:
the largest number that can be stored in this set

equals

public boolean equals(java.lang.Object obj)
Description copied from interface: IntSet
Two sets are equal if they consists of the same elements.

Specified by:
equals in interface IntSet

hashCode

public int hashCode()
Specified by:
hashCode in interface IntSet

isEmpty

public boolean isEmpty()
Description copied from interface: IntSet
Returns true if this set is empty; false otherwise.

Specified by:
isEmpty in interface IntSet
Overrides:
isEmpty in class AbstractIntCollection

addAll

public boolean addAll(IntCollection c)
Description copied from interface: IntSet
Adds all of the elements in the specified collection to this set if they're not already present, and if they fall within this set's domain. If the specified collection is also a set, the addAll operation effectively modifies this set so that its value is the union of the two sets, intersected with this set's domain. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress.

Specified by:
addAll in interface IntSet
Overrides:
addAll in class AbstractIntCollection

removeAll

public boolean removeAll(IntCollection c)
Description copied from interface: IntSet
Removes from this set all of its elements that are contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the asymmetric set difference of the two sets.

Specified by:
removeAll in interface IntSet
Overrides:
removeAll in class AbstractIntCollection

retainAll

public boolean retainAll(IntCollection c)
Description copied from interface: IntSet
Retains only the elements in this set that are contained in the specified collection. In other words, removes from this set all of its elements that are not contained in the specified collection. If the specified collection is also a set, this operation effectively modifies this set so that its value is the intersection of the two sets.

Specified by:
retainAll in interface IntSet
Overrides:
retainAll in class AbstractIntCollection

containsInterval

public boolean containsInterval(int first,
                                int last)
Description copied from interface: IntSet
Returns true if this set contains all the numbers between first and last, inclusive; false otherwise.

Specified by:
containsInterval in interface IntSet
Returns:
true if this set contains the specified interval; false otherwise

addInterval

public boolean addInterval(int first,
                           int last)
Description copied from interface: IntSet
Adds to this set all the numbers between first and last, inclusive, that are not already present in this set and beint to this set's domain.

Specified by:
addInterval in interface IntSet
Parameters:
first - the beginning of the interval (inclusive)
last - the end of the interval (inclusive)
Returns:
true if this set changed as a result of the call
See Also:
IntSet.add(int)

removeInterval

public boolean removeInterval(int first,
                              int last)
Description copied from interface: IntSet
Removes from this set all the numbers between first and last, inclusive.

Specified by:
removeInterval in interface IntSet
Parameters:
first - the beginning of the interval (inclusive)
last - the end of the interval (inclusive)
Returns:
true if this set changed as a result of the call
See Also:
IntSet.remove(int), #removeAll()

retainInterval

public boolean retainInterval(int first,
                              int last)
Description copied from interface: IntSet
Retains in this set only the numbers between first and last, inclusive. In other words, removes from this set all the numbers outside the specified interval.

Specified by:
retainInterval in interface IntSet
Parameters:
first - the beginning of the interval (inclusive)
last - the end of the interval (inclusive)
Returns:
true if this set changed as a result of the call
See Also:
#retainAll()

complementSet

public IntSet complementSet()
Description copied from interface: IntSet
Returns a complement view of this set. Complement view is a set that has the same domain as this set, and consists of all numbers from the domain that are not contained in this set. Changes done to this set are reflected in the complement view after it is created.

Specified by:
complementSet in interface IntSet
Returns:
the complement view of this set