|
||||||||||
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(int e)
Adds the specified number to this set if it is not already present and if it falls within the domain. |
boolean |
addAll(IntCollection 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(int first,
int last)
Adds to this set all the numbers between first and last, inclusive, that are not already present in this set and beint to this set's domain. |
void |
clear()
Removes all of the elements from this set. |
IntSet |
complementSet()
Returns a complement view of this set. |
boolean |
contains(int e)
Returns true if this set contains the specified number; false otherwise. |
boolean |
containsAll(IntCollection c)
Returns true if this set contains all of the elements of the specified collection. |
boolean |
containsInterval(int first,
int 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. |
IntIterator |
iterator()
Returns the iterator over numbers contained in this set. |
int |
max()
The largest number that can be stored in this set. |
int |
min()
The smallest number that can be stored in this set. |
boolean |
remove(int e)
Removes the specified number from this set if it is present. |
boolean |
removeAll(IntCollection c)
Removes from this set all of its elements that are contained in the specified collection. |
boolean |
removeInterval(int first,
int last)
Removes from this set all the numbers between first and last, inclusive. |
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 |
size()
Returns the number of elements in this set. |
int |
size64()
Returns the number of elements in this set. |
int[] |
toArray()
Returns the newly allocated array containing all numbers from this set, in the order returned by its iterator. |
int[] |
toArray(int[] a)
Returns an array containing all of the numbers in this set. |
Method Detail |
public int min()
public int max()
public int size()
size
in interface IntCollection
public int size64()
size64
in interface IntCollection
public boolean isEmpty()
isEmpty
in interface IntCollection
public boolean contains(int e)
contains
in interface IntCollection
public IntIterator iterator()
iterator
in interface IntCollection
public int[] toArray()
toArray
in interface IntCollection
public int[] toArray(int[] 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 IntCollection
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(int e)
add
in interface IntCollection
e
- number to be added to this collection
public boolean remove(int e)
remove
in interface IntCollection
e
- number to be removed from this collection
public boolean containsAll(IntCollection c)
containsAll
in interface IntCollection
c
- collection to be checked for containment in this set
java.lang.NullPointerException
- if the specified collection is nullcontains(int)
public boolean addAll(IntCollection c)
addAll
in interface IntCollection
c
- collection containing elements to be added to this set
java.lang.NullPointerException
- if the specified collection is nulladd(int)
public boolean retainAll(IntCollection c)
retainAll
in interface IntCollection
c
- collection containing elements to be retained in this set
remove(int)
public boolean removeAll(IntCollection c)
removeAll
in interface IntCollection
c
- collection containing elements to be removed from this set
remove(int)
public IntSet complementSet()
public void clear()
clear
in interface IntCollection
public boolean equals(java.lang.Object o)
equals
in interface IntCollection
public int hashCode()
hashCode
in interface IntCollection
public boolean containsInterval(int first, int last)
public boolean addInterval(int first, int last)
first
- the beginning of the interval (inclusive)last
- the end of the interval (inclusive)
add(int)
public boolean retainInterval(int first, int last)
first
- the beginning of the interval (inclusive)last
- the end of the interval (inclusive)
#retainAll()
public boolean removeInterval(int first, int last)
first
- the beginning of the interval (inclusive)last
- the end of the interval (inclusive)
remove(int)
,
#removeAll()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |