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

java.lang.Object
  extended byedu.emory.mathcs.util.collections.ints.AbstractIntCollection
      extended byedu.emory.mathcs.util.collections.ints.AbstractIntSet
          extended byedu.emory.mathcs.util.collections.ints.AbstractIntSortedSet
All Implemented Interfaces:
IntCollection, IntSet, IntSortedSet
Direct Known Subclasses:
AbstractIntInterval, AbstractIntInterval.ComplementView, AbstractIntSortedSet.AbstractComplementSubView, AbstractIntSortedSet.AbstractSubView, IntIntervalSet

public abstract class AbstractIntSortedSet
extends AbstractIntSet
implements IntSortedSet

Convenience subclass for sorted int sets.

Version:
1.0
Author:
Dawid Kurzyniec

Nested Class Summary
protected static class AbstractIntSortedSet.AbstractComplementSubView
           
protected static class AbstractIntSortedSet.AbstractSubView
           
protected static class AbstractIntSortedSet.ForwardIntervalItemIterator
           
protected static class AbstractIntSortedSet.ReverseIntervalItemIterator
           
 
Constructor Summary
AbstractIntSortedSet()
           
 
Method Summary
 int ceiling(int e)
          Returns the smallest number in this set >= e.
 IntIterator descendingIterator()
          Returns an iterator over numbers in this set, in a decreasing numerical order.
 int first()
          Returns the smallest number in this set.
 IntInterval firstInterval()
          Returns the first (left-most), widest interval contained in this set, or null if this set is empty.
 int floor(int e)
          Returns the largest number in this set <= e.
 IntSortedSet headSet(int last)
          A subset view containing all elements from this set that are not greater than last.
 int higher(int e)
          Returns the smallest number in this set > e.
 int intervalCount()
          Returns the minimum count of intervals into which this set can be decomposed.
 boolean isEmpty()
          Returns true if this set is empty; false otherwise.
 IntIterator iterator()
          Returns an iterator over numbers in this set, in an increasing numerical order.
 int last()
          Returns the largest number in this set.
 IntInterval lastInterval()
          Returns the last (right-most), widest interval contained in this set, or null if this set is empty.
 int lower(int e)
          Returns the largest number in this set < e.
 int pollFirst()
          Returns and removes the smallest number in this set.
 IntInterval pollFirstInterval()
          Returns and removes the first (left-most), widest interval contained in this set, or null if this set is empty.
 int pollLast()
          Returns and removes the largest number in this set.
 IntInterval pollLastInterval()
          Returns and removes the last (right-most), widest interval contained in this set, or null if this set is empty.
 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.
 int size64()
          Returns the number of elements in this set.
 IntSortedSet tailSet(int first)
          A subset view containing all elements from this set that are not smaller than first.
 java.lang.String toCompactString()
          Returns the interval-string representation of this set (suitable for representing sets that are possibly large but clustered).
 
Methods inherited from class edu.emory.mathcs.util.collections.ints.AbstractIntSet
addAll, addInterval, complementSet, containsInterval, equals, hashCode, max, min, removeAll, removeInterval
 
Methods inherited from class edu.emory.mathcs.util.collections.ints.AbstractIntCollection
add, clear, contains, containsAll, remove, size, 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.IntSortedSet
ceilingInterval, descendingIntervalIterator, enclosingInterval, floorInterval, higherInterval, intervalIterator, lowerInterval, subSet, toString
 
Methods inherited from interface edu.emory.mathcs.util.collections.ints.IntSet
add, addAll, addInterval, clear, complementSet, contains, containsAll, containsInterval, equals, hashCode, max, min, remove, removeAll, removeInterval, size, toArray, toArray
 

Constructor Detail

AbstractIntSortedSet

public AbstractIntSortedSet()
Method Detail

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 AbstractIntSet

size64

public int size64()
Description copied from interface: IntSet
Returns the number of elements in this set.

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

intervalCount

public int intervalCount()
Description copied from interface: IntSortedSet
Returns the minimum count of intervals into which this set can be decomposed. For instance, {1, 3,4,5, 8,9}.intervalCount() == 3.

Specified by:
intervalCount in interface IntSortedSet
Returns:
int the interval count of this set.

first

public int first()
Description copied from interface: IntSortedSet
Returns the smallest number in this set.

Specified by:
first in interface IntSortedSet
Returns:
the smallest number in this set.

last

public int last()
Description copied from interface: IntSortedSet
Returns the largest number in this set.

Specified by:
last in interface IntSortedSet
Returns:
the largest number in this set.

pollFirst

public int pollFirst()
Description copied from interface: IntSortedSet
Returns and removes the smallest number in this set.

Specified by:
pollFirst in interface IntSortedSet
Returns:
the smallest number in this set.

pollLast

public int pollLast()
Description copied from interface: IntSortedSet
Returns and removes the largest number in this set.

Specified by:
pollLast in interface IntSortedSet
Returns:
the smallest number in this set.

firstInterval

public IntInterval firstInterval()
Description copied from interface: IntSortedSet
Returns the first (left-most), widest interval contained in this set, or null if this set is empty.

Specified by:
firstInterval in interface IntSortedSet
Returns:
the first interval contained in this set

lastInterval

public IntInterval lastInterval()
Description copied from interface: IntSortedSet
Returns the last (right-most), widest interval contained in this set, or null if this set is empty.

Specified by:
lastInterval in interface IntSortedSet
Returns:
the last interval contained in this set

pollFirstInterval

public IntInterval pollFirstInterval()
Description copied from interface: IntSortedSet
Returns and removes the first (left-most), widest interval contained in this set, or null if this set is empty.

Specified by:
pollFirstInterval in interface IntSortedSet
Returns:
the first interval contained in this set

pollLastInterval

public IntInterval pollLastInterval()
Description copied from interface: IntSortedSet
Returns and removes the last (right-most), widest interval contained in this set, or null if this set is empty.

Specified by:
pollLastInterval in interface IntSortedSet
Returns:
the last interval contained in this set

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 AbstractIntSet

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
Overrides:
retainInterval in class AbstractIntSet

higher

public int higher(int e)
Description copied from interface: IntSortedSet
Returns the smallest number in this set > e.

Specified by:
higher in interface IntSortedSet
Returns:
the smallest number in this set > e.

ceiling

public int ceiling(int e)
Description copied from interface: IntSortedSet
Returns the smallest number in this set >= e.

Specified by:
ceiling in interface IntSortedSet
Returns:
the smallest number in this set >= e.

lower

public int lower(int e)
Description copied from interface: IntSortedSet
Returns the largest number in this set < e.

Specified by:
lower in interface IntSortedSet
Returns:
the largest number in this set < e.

floor

public int floor(int e)
Description copied from interface: IntSortedSet
Returns the largest number in this set <= e.

Specified by:
floor in interface IntSortedSet
Returns:
the largest number in this set <= e.

headSet

public IntSortedSet headSet(int last)
Description copied from interface: IntSortedSet
A subset view containing all elements from this set that are not greater than last. More precisely, the view is narrowed to the domain [MIN_VALUE, max]. Hence, complement set of this set will NOT include any elements > max.

Specified by:
headSet in interface IntSortedSet
Parameters:
last - the maximum element of this view (inclusive).
Returns:
the headset view

tailSet

public IntSortedSet tailSet(int first)
Description copied from interface: IntSortedSet
A subset view containing all elements from this set that are not smaller than first. More precisely, the view is narrowed to the domain [min, MAX_VALUE]. Hence, complement set of this set will NOT include any elements < min.

Specified by:
tailSet in interface IntSortedSet
Parameters:
first - the minimum element of this view (inclusive).
Returns:
the tailset view

iterator

public IntIterator iterator()
Description copied from interface: IntSortedSet
Returns an iterator over numbers in this set, in an increasing numerical order.

Specified by:
iterator in interface IntSortedSet
Specified by:
iterator in class AbstractIntCollection

descendingIterator

public IntIterator descendingIterator()
Description copied from interface: IntSortedSet
Returns an iterator over numbers in this set, in a decreasing numerical order.

Specified by:
descendingIterator in interface IntSortedSet
Returns:
a descending iterator over numbers in this set

toCompactString

public java.lang.String toCompactString()
Description copied from interface: IntSortedSet
Returns the interval-string representation of this set (suitable for representing sets that are possibly large but clustered).

Specified by:
toCompactString in interface IntSortedSet
Returns:
String