edu.emory.mathcs.util.collections.shorts
Class AbstractShortSortedSet

java.lang.Object
  extended byedu.emory.mathcs.util.collections.shorts.AbstractShortCollection
      extended byedu.emory.mathcs.util.collections.shorts.AbstractShortSet
          extended byedu.emory.mathcs.util.collections.shorts.AbstractShortSortedSet
All Implemented Interfaces:
ShortCollection, ShortSet, ShortSortedSet
Direct Known Subclasses:
AbstractShortInterval, AbstractShortInterval.ComplementView, AbstractShortSortedSet.AbstractComplementSubView, AbstractShortSortedSet.AbstractSubView, ShortIntervalSet

public abstract class AbstractShortSortedSet
extends AbstractShortSet
implements ShortSortedSet

Convenience subclass for sorted short sets.

Version:
1.0
Author:
Dawid Kurzyniec

Nested Class Summary
protected static class AbstractShortSortedSet.AbstractComplementSubView
           
protected static class AbstractShortSortedSet.AbstractSubView
           
protected static class AbstractShortSortedSet.ForwardIntervalItemIterator
           
protected static class AbstractShortSortedSet.ReverseIntervalItemIterator
           
 
Constructor Summary
AbstractShortSortedSet()
           
 
Method Summary
 short ceiling(short e)
          Returns the smallest number in this set >= e.
 ShortIterator descendingIterator()
          Returns an iterator over numbers in this set, in a decreasing numerical order.
 short first()
          Returns the smallest number in this set.
 ShortInterval firstInterval()
          Returns the first (left-most), widest interval contained in this set, or null if this set is empty.
 short floor(short e)
          Returns the largest number in this set <= e.
 ShortSortedSet headSet(short last)
          A subset view containing all elements from this set that are not greater than last.
 short higher(short 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.
 ShortIterator iterator()
          Returns an iterator over numbers in this set, in an increasing numerical order.
 short last()
          Returns the largest number in this set.
 ShortInterval lastInterval()
          Returns the last (right-most), widest interval contained in this set, or null if this set is empty.
 short lower(short e)
          Returns the largest number in this set < e.
 short pollFirst()
          Returns and removes the smallest number in this set.
 ShortInterval pollFirstInterval()
          Returns and removes the first (left-most), widest interval contained in this set, or null if this set is empty.
 short pollLast()
          Returns and removes the largest number in this set.
 ShortInterval pollLastInterval()
          Returns and removes the last (right-most), widest interval contained in this set, or null if this set is empty.
 boolean retainAll(ShortCollection c)
          Retains only the elements in this set that are contained in the specified collection.
 boolean retainInterval(short first, short last)
          Retains in this set only the numbers between first and last, inclusive.
 int size()
          Returns the number of elements in this set.
 ShortSortedSet tailSet(short 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.shorts.AbstractShortSet
addAll, addInterval, complementSet, containsInterval, equals, hashCode, max, min, removeAll, removeInterval
 
Methods inherited from class edu.emory.mathcs.util.collections.shorts.AbstractShortCollection
add, clear, contains, containsAll, remove, 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.shorts.ShortSortedSet
ceilingInterval, descendingIntervalIterator, enclosingInterval, floorInterval, higherInterval, intervalIterator, lowerInterval, subSet, toString
 
Methods inherited from interface edu.emory.mathcs.util.collections.shorts.ShortSet
add, addAll, addInterval, clear, complementSet, contains, containsAll, containsInterval, equals, hashCode, max, min, remove, removeAll, removeInterval, toArray, toArray
 

Constructor Detail

AbstractShortSortedSet

public AbstractShortSortedSet()
Method Detail

isEmpty

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

Specified by:
isEmpty in interface ShortSet
Overrides:
isEmpty in class AbstractShortSet

size

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

Specified by:
size in interface ShortSet
Overrides:
size in class AbstractShortCollection

intervalCount

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

first

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

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

last

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

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

pollFirst

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

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

pollLast

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

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

firstInterval

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

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

lastInterval

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

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

pollFirstInterval

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

pollLastInterval

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

retainAll

public boolean retainAll(ShortCollection c)
Description copied from interface: ShortSet
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 ShortSet
Overrides:
retainAll in class AbstractShortSet

retainInterval

public boolean retainInterval(short first,
                              short last)
Description copied from interface: ShortSet
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 ShortSet
Overrides:
retainInterval in class AbstractShortSet

higher

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

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

ceiling

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

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

lower

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

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

floor

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

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

headSet

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

tailSet

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

iterator

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

Specified by:
iterator in interface ShortSortedSet
Specified by:
iterator in class AbstractShortCollection

descendingIterator

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

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

toCompactString

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

Specified by:
toCompactString in interface ShortSortedSet
Returns:
String