|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 min()
and 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 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).
Method Summary | |
boolean |
add(short e)
Adds the specified number to this set if it is not already present and if it falls within the domain. |
boolean |
addAll(ShortCollection 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(short first,
short last)
Adds to this set all the numbers between first and last, inclusive, that are not already present in this set and beshort to this set's domain. |
void |
clear()
Removes all of the elements from this set. |
ShortSet |
complementSet()
Returns a complement view of this set. |
boolean |
contains(short e)
Returns true if this set contains the specified number; false otherwise. |
boolean |
containsAll(ShortCollection c)
Returns true if this set contains all of the elements of the specified collection. |
boolean |
containsInterval(short first,
short last)
Returns true if this set contains all the numbers between first and last, inclusive; false otherwise. |
boolean |
equals(java.lang.Object o)
Two sets are equal if they consists of the same elements. |
int |
hashCode()
|
boolean |
isEmpty()
Returns true if this set is empty; false otherwise. |
ShortIterator |
iterator()
Returns the iterator over numbers contained in this set. |
short |
max()
The largest number that can be stored in this set. |
short |
min()
The smallest number that can be stored in this set. |
boolean |
remove(short e)
Removes the specified number from this set if it is present. |
boolean |
removeAll(ShortCollection c)
Removes from this set all of its elements that are contained in the specified collection. |
boolean |
removeInterval(short first,
short last)
Removes from this set all the numbers between first and last, inclusive. |
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. |
short[] |
toArray()
Returns the newly allocated array containing all numbers from this set, in the order returned by its iterator. |
short[] |
toArray(short[] a)
Returns an array containing all of the numbers in this set. |
Method Detail |
public short min()
public short max()
public int size()
size
in interface ShortCollection
public boolean isEmpty()
isEmpty
in interface ShortCollection
public boolean contains(short e)
contains
in interface ShortCollection
public ShortIterator iterator()
iterator
in interface ShortCollection
public short[] toArray()
toArray
in interface ShortCollection
public short[] toArray(short[] a)
If this set makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.
Like the toArray()
method, this method acts as bridge between
array-based and collection-based APIs. Further, this method may,
under certain circumstances, be used to save allocation costs.
toArray
in interface ShortCollection
a
- the array into which the elements of this set are to be
stored, if it is big enough; otherwise, a new array is allocated
for this purpose.
java.lang.NullPointerException
- if the specified array is nullpublic boolean add(short e)
add
in interface ShortCollection
e
- number to be added to this collection
public boolean remove(short e)
remove
in interface ShortCollection
e
- number to be removed from this collection
public boolean containsAll(ShortCollection c)
containsAll
in interface ShortCollection
c
- collection to be checked for containment in this set
java.lang.NullPointerException
- if the specified collection is nullcontains(short)
public boolean addAll(ShortCollection c)
addAll
in interface ShortCollection
c
- collection containing elements to be added to this set
java.lang.NullPointerException
- if the specified collection is nulladd(short)
public boolean retainAll(ShortCollection c)
retainAll
in interface ShortCollection
c
- collection containing elements to be retained in this set
remove(short)
public boolean removeAll(ShortCollection c)
removeAll
in interface ShortCollection
c
- collection containing elements to be removed from this set
remove(short)
public ShortSet complementSet()
public void clear()
clear
in interface ShortCollection
public boolean equals(java.lang.Object o)
equals
in interface ShortCollection
public int hashCode()
hashCode
in interface ShortCollection
public boolean containsInterval(short first, short last)
public boolean addInterval(short first, short last)
first
- the beginning of the interval (inclusive)last
- the end of the interval (inclusive)
add(short)
public boolean retainInterval(short first, short last)
first
- the beginning of the interval (inclusive)last
- the end of the interval (inclusive)
#retainAll()
public boolean removeInterval(short first, short last)
first
- the beginning of the interval (inclusive)last
- the end of the interval (inclusive)
remove(short)
,
#removeAll()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |