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

java.lang.Object
  extended byedu.emory.mathcs.util.collections.longs.AbstractLongCollection
      extended byedu.emory.mathcs.util.collections.longs.AbstractLongSet
          extended byedu.emory.mathcs.util.collections.longs.AbstractLongSortedSet
All Implemented Interfaces:
LongCollection, LongSet, LongSortedSet
Direct Known Subclasses:
AbstractLongInterval, AbstractLongInterval.ComplementView, AbstractLongSortedSet.AbstractComplementSubView, AbstractLongSortedSet.AbstractSubView, LongIntervalSet

public abstract class AbstractLongSortedSet
extends AbstractLongSet
implements LongSortedSet

Convenience subclass for sorted long sets.

Version:
1.0
Author:
Dawid Kurzyniec

Nested Class Summary
protected static class AbstractLongSortedSet.AbstractComplementSubView
           
protected static class AbstractLongSortedSet.AbstractSubView
           
protected static class AbstractLongSortedSet.ForwardIntervalItemIterator
           
protected static class AbstractLongSortedSet.ReverseIntervalItemIterator
           
 
Constructor Summary
AbstractLongSortedSet()
           
 
Method Summary
 long ceiling(long e)
          Returns the smallest number in this set >= e.
 LongIterator descendingIterator()
          Returns an iterator over numbers in this set, in a decreasing numerical order.
 long first()
          Returns the smallest number in this set.
 LongInterval firstInterval()
          Returns the first (left-most), widest interval contained in this set, or null if this set is empty.
 long floor(long e)
          Returns the largest number in this set <= e.
 LongSortedSet headSet(long last)
          A subset view containing all elements from this set that are not greater than last.
 long higher(long 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.
 LongIterator iterator()
          Returns an iterator over numbers in this set, in an increasing numerical order.
 long last()
          Returns the largest number in this set.
 LongInterval lastInterval()
          Returns the last (right-most), widest interval contained in this set, or null if this set is empty.
 long lower(long e)
          Returns the largest number in this set < e.
 long pollFirst()
          Returns and removes the smallest number in this set.
 LongInterval pollFirstInterval()
          Returns and removes the first (left-most), widest interval contained in this set, or null if this set is empty.
 long pollLast()
          Returns and removes the largest number in this set.
 LongInterval pollLastInterval()
          Returns and removes the last (right-most), widest interval contained in this set, or null if this set is empty.
 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.
 long size64()
          // PREPROC: Long,Int only Returns the number of elements in this set.
 LongSortedSet tailSet(long 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.longs.AbstractLongSet
addAll, addInterval, complementSet, containsInterval, equals, hashCode, max, min, removeAll, removeInterval
 
Methods inherited from class edu.emory.mathcs.util.collections.longs.AbstractLongCollection
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.longs.LongSortedSet
ceilingInterval, descendingIntervalIterator, enclosingInterval, floorInterval, higherInterval, intervalIterator, lowerInterval, subSet, toString
 
Methods inherited from interface edu.emory.mathcs.util.collections.longs.LongSet
add, addAll, addInterval, clear, complementSet, contains, containsAll, containsInterval, equals, hashCode, max, min, remove, removeAll, removeInterval, size, toArray, toArray
 

Constructor Detail

AbstractLongSortedSet

public AbstractLongSortedSet()
Method Detail

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 AbstractLongSet

size64

public long size64()
Description copied from interface: LongSet
// PREPROC: Long,Int only Returns the number of elements in this set. // PREPROC: Long,Int only

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

intervalCount

public int intervalCount()
Description copied from interface: LongSortedSet
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 LongSortedSet
Returns:
int the interval count of this set.

first

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

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

last

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

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

pollFirst

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

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

pollLast

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

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

firstInterval

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

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

lastInterval

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

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

pollFirstInterval

public LongInterval pollFirstInterval()
Description copied from interface: LongSortedSet
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 LongSortedSet
Returns:
the first interval contained in this set

pollLastInterval

public LongInterval pollLastInterval()
Description copied from interface: LongSortedSet
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 LongSortedSet
Returns:
the last interval contained in this set

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 AbstractLongSet

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

higher

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

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

ceiling

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

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

lower

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

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

floor

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

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

headSet

public LongSortedSet headSet(long last)
Description copied from interface: LongSortedSet
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 LongSortedSet
Parameters:
last - the maximum element of this view (inclusive).
Returns:
the headset view

tailSet

public LongSortedSet tailSet(long first)
Description copied from interface: LongSortedSet
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 LongSortedSet
Parameters:
first - the minimum element of this view (inclusive).
Returns:
the tailset view

iterator

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

Specified by:
iterator in interface LongSortedSet
Specified by:
iterator in class AbstractLongCollection

descendingIterator

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

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

toCompactString

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

Specified by:
toCompactString in interface LongSortedSet
Returns:
String