|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Sorted set is a collection with no duplicate elements. Primitive sets have
some features not found in object sets. A primitive set is
associated with a domain with boundaries defined by ShortSet.min()
and ShortSet.max()
. All numbers contained within this set must fit
between min and max, inclusive. Attempt to add a number from outside the
domain will have no effect.
It is possible to obtain a complement view of a
primitive set, using ShortSet.complementSet()
. The complement view contains
all numbers between min and max, inclusive, which are not contained in
this set. (In other words, complement view never contains numbers from
outside of the domain of this set).
Contrary to standard Java collections, intervals in this primitive collection package are inclusive on both sides. In other words, interval [min, max] contains all numbers c such that min <= c <= max. (Otherwise, MAX_VALUE could not be put in the set).
It is possible to obtain a subset view of a sorted set, using one of
the methods #subSet()
, #headSet()
, and #tailSet()
.
The subset view narrows the domain, and its size is thus never bigger than
that of this set.
Sorted sets define a family of navigation methods, analogous to that
found in NavigableSet
.
Method Summary | |
short |
ceiling(short e)
Returns the smallest number in this set >= e. |
ShortInterval |
ceilingInterval(short e)
Returns the smallest (left-most), widest interval contained in this set which elements are not all smaller than the specified number. |
java.util.Iterator |
descendingIntervalIterator()
Returns an iterator over intervals of this set, in a decreasing numerical order. |
ShortIterator |
descendingIterator()
Returns an iterator over numbers in this set, in a decreasing numerical order. |
ShortInterval |
enclosingInterval(short e)
Returns the widest interval contained in this set that includes the specified number, or null if this set does not include the specified number. |
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. |
ShortInterval |
floorInterval(short e)
Returns the largest (right-most), widest interval contained in this set which elements are not all greater than the specified number. |
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. |
ShortInterval |
higherInterval(short e)
Returns the smallest (left-most), widest interval contained in this set which all elements are strictly greater than the specified number. |
int |
intervalCount()
Returns the minimum count of intervals into which this set can be decomposed. |
java.util.Iterator |
intervalIterator()
Returns an iterator over intervals of this set, in an increasing numerical order. |
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. |
ShortInterval |
lowerInterval(short e)
Returns the largest and widest interval contained in this set which all elements are strictly less than the specified number. |
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. |
ShortSortedSet |
subSet(short first,
short last)
A subset view containing all elements from this set between first, inclusive, and last, inclusive. |
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). |
java.lang.String |
toString()
|
Methods inherited from interface edu.emory.mathcs.util.collections.shorts.ShortSet |
add, addAll, addInterval, clear, complementSet, contains, containsAll, containsInterval, equals, hashCode, isEmpty, max, min, remove, removeAll, removeInterval, retainAll, retainInterval, size, toArray, toArray |
Method Detail |
public ShortSortedSet subSet(short first, short last)
first
- the minimum element of this view (inclusive).last
- the maximum element of this view (inclusive).
public ShortSortedSet headSet(short last)
last
- the maximum element of this view (inclusive).
public ShortSortedSet tailSet(short first)
first
- the minimum element of this view (inclusive).
public short first()
java.util.NoSuchElementException
- if the set is empty.public short last()
java.util.NoSuchElementException
- if the set is empty.public short ceiling(short e)
java.util.NoSuchElementException
- if all elements are < e.public short higher(short e)
java.util.NoSuchElementException
- if all elements are <= e.public short floor(short e)
java.util.NoSuchElementException
- if all elements are > e.public short lower(short e)
java.util.NoSuchElementException
- if all elements are >= e.public short pollFirst()
java.util.NoSuchElementException
- if the set is empty.public short pollLast()
java.util.NoSuchElementException
- if the set is empty.public int intervalCount()
public java.util.Iterator intervalIterator()
public java.util.Iterator descendingIntervalIterator()
public ShortIterator iterator()
iterator
in interface ShortSet
public ShortIterator descendingIterator()
public ShortInterval firstInterval()
public ShortInterval lastInterval()
public ShortInterval enclosingInterval(short e)
public ShortInterval lowerInterval(short e)
public ShortInterval higherInterval(short e)
public ShortInterval floorInterval(short e)
public ShortInterval ceilingInterval(short e)
public ShortInterval pollFirstInterval()
public ShortInterval pollLastInterval()
public java.lang.String toString()
public java.lang.String toCompactString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |