edu.emory.mathcs.util.collections.longs
Class AbstractLongSet

java.lang.Object
  extended byedu.emory.mathcs.util.collections.longs.AbstractLongCollection
      extended byedu.emory.mathcs.util.collections.longs.AbstractLongSet
All Implemented Interfaces:
LongCollection, LongSet
Direct Known Subclasses:
AbstractLongSortedSet, LongRadkeHashSet

public abstract class AbstractLongSet
extends AbstractLongCollection
implements LongSet

Convenience subclass for long sets.

Version:
1.0
Author:
Dawid Kurzyniec

Constructor Summary
protected AbstractLongSet()
           
 
Method Summary
 boolean addAll(LongCollection 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(long first, long last)
          Adds to this set all the numbers between first and last, inclusive, that are not already present in this set and belong to this set's domain.
 LongSet complementSet()
          Returns a complement view of this set.
 boolean containsInterval(long first, long 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.
 long max()
          The largest number that can be stored in this set.
 long min()
          The smallest number that can be stored in this set.
 boolean removeAll(LongCollection c)
          Removes from this set all of its elements that are contained in the specified collection.
 boolean removeInterval(long first, long last)
          Removes from this set all the numbers between first and last, inclusive.
 boolean retainAll(LongCollection c)
          Retains only the elements in this set that are contained in the specified collection.
 boolean retainInterval(long first, long last)
          Retains in this set only the numbers between first and last, inclusive.
 
Methods inherited from class edu.emory.mathcs.util.collections.longs.AbstractLongCollection
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.longs.LongSet
add, clear, contains, containsAll, iterator, remove, size, size64, toArray, toArray
 

Constructor Detail

AbstractLongSet

protected AbstractLongSet()
Method Detail

min

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

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

max

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

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

equals

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

Specified by:
equals in interface LongSet

hashCode

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

isEmpty

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

Specified by:
isEmpty in interface LongSet
Overrides:
isEmpty in class AbstractLongCollection

addAll

public boolean addAll(LongCollection c)
Description copied from interface: LongSet
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 LongSet
Overrides:
addAll in class AbstractLongCollection

removeAll

public boolean removeAll(LongCollection c)
Description copied from interface: LongSet
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 LongSet
Overrides:
removeAll in class AbstractLongCollection

retainAll

public boolean retainAll(LongCollection c)
Description copied from interface: LongSet
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 LongSet
Overrides:
retainAll in class AbstractLongCollection

containsInterval

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

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

addInterval

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

Specified by:
addInterval in interface LongSet
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:
LongSet.add(long)

removeInterval

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

Specified by:
removeInterval in interface LongSet
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:
LongSet.remove(long), #removeAll()

retainInterval

public boolean retainInterval(long first,
                              long last)
Description copied from interface: LongSet
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 LongSet
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 LongSet complementSet()
Description copied from interface: LongSet
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 LongSet
Returns:
the complement view of this set