public interface IntSet extends IntCollection, Cloneable
ints: set int
Modifier and Type | Method and Description |
---|---|
boolean |
add(int i)
Adds the given integer to this set if not already present
and returns true.
|
boolean |
addAll(IntCollection c)
Adds all of the elements in the specified collection to this set
if they're not already present.
|
int |
ceil(int i)
Returns the smallest element in this set that
is greater than or equal to i.
|
void |
clear()
Removes all elements from this set.
|
IntSet |
clone()
Returns a copy of this IntSet.
|
boolean |
contains(int i)
Returns true if i is in this set.
|
boolean |
containsAll(IntCollection c)
Returns true if the elements of c are a subset of this set.
|
boolean |
equals(Object o)
Compares the specified object with this set for equality.
|
int |
floor(int i)
Returns the largest element in this set that
is smaller than or equal to i.
|
int |
hashCode()
Returns the hash code value for this set.
|
boolean |
isEmpty()
Returns true if this set has no elements;
otherwise returns false.
|
IntIterator |
iterator()
Returns an iterator over the integers in this set,
in the ascending element order.
|
IntIterator |
iterator(int from,
int to)
Returns an iterator over the elements of this set that
are in the closed range [from..to].
|
int |
max()
Returns the largest element in this set.
|
int |
min()
Returns the smallest element in this set.
|
boolean |
remove(int i)
Removes the given integer from this set if already present and
returns true.
|
boolean |
removeAll(IntCollection c)
Removes from this set all of its elements that are contained in the
specified set.
|
boolean |
retainAll(IntCollection c)
Retains only the elements in this set that are contained in the
specified set.
|
int |
size()
Returns the cardinality of this set.
|
int[] |
toArray()
Returns an array containing all of the elements in this set in the
ascending order.
|
int[] |
toArray(int[] array)
Copies the elements of this set into the specified array, in the ascending
order, provided that the array is large enough.
|
boolean add(int i)
add
in interface IntCollection
this.ints' = this.ints + i
IllegalArgumentException
- this is a bounded set
and i is out of boundsboolean addAll(IntCollection c)
addAll
in interface IntCollection
this.ints' = this.ints + { i: int | c.contains(i) }
NullPointerException
- c = nullUnsupportedOperationException
- this is an unmodifiable setIllegalArgumentException
- some aspect of an element of the specified
collection prevents it from being added to this collection.int ceil(int i)
NoSuchElementException
- no this.ints || i > this.max()void clear()
clear
in interface IntCollection
no this.ints'
IntSet clone() throws CloneNotSupportedException
CloneNotSupportedException
- this is not cloneableboolean contains(int i)
contains
in interface IntCollection
boolean containsAll(IntCollection c)
containsAll
in interface IntCollection
NullPointerException
- c = nullboolean equals(Object o)
int floor(int i)
NoSuchElementException
- no this.ints || i < this.min()int hashCode()
Ints.superFastHash(int[])
of the elements in the set,
taken in the ascending order of values.
This ensures that s1.equals(s2) implies that s1.hashCode()==s2.hashCode()
for any two IntSets s1 and s2, as required by the general contract of the Object.hashCode method.boolean isEmpty()
isEmpty
in interface IntCollection
IntIterator iterator()
iterator
in interface IntCollection
IntIterator iterator(int from, int to)
int max()
NoSuchElementException
- no this.intsint min()
NoSuchElementException
- no this.intsboolean remove(int i)
remove
in interface IntCollection
this.ints' = this.ints - i
boolean removeAll(IntCollection c)
removeAll
in interface IntCollection
this.ints' = this.ints - { i: int | c.contains(i) }
NullPointerException
- s = nullUnsupportedOperationException
- this is an unmodifiable setboolean retainAll(IntCollection c)
retainAll
in interface IntCollection
this.ints' = this.ints & { i: int | c.contains(i) }
NullPointerException
- s = nullUnsupportedOperationException
- this is an unmodifiable setint size()
size
in interface IntCollection
int[] toArray()
toArray
in interface IntCollection
int[] toArray(int[] array)
toArray
in interface IntCollection
array.length>=this.size() => all i: [0..this.size()) | array'[i] in this.ints and #{e: this.ints | e < array'[i]} = i
NullPointerException
- array = null
© Emina Torlak 2005-present