public interface IntVector extends IntCollection
length: int
elements: [0..size) ->one int
Modifier and Type | Method and Description |
---|---|
boolean |
add(int element)
Adds the specified element to the end of this vector (optional
operation), and returns true if this vector has changed as a result
of the call.
|
void |
add(int index,
int element)
Inserts the specified element at the specified position in this vector
(optional operation), and returns true if this vector has changed as a result of the call.
|
boolean |
addAll(IntCollection c)
Appends the specified elements to the end of this vector (optional
operation), and returns true if this vector has changed as a result of the call.
|
boolean |
addAll(int index,
IntCollection c)
Inserts the specified elements at the specified position in this vector
(optional operation), and returns true if this vector has changed as a result of the call.
|
void |
clear()
Removes all of the elements from this vector (optional operation).
|
boolean |
contains(int element)
Returns true if this vector contains the specified element.
|
boolean |
equals(Object o)
Compares the specified object with this vector for equality.
|
int |
get(int index)
Returns the element at the specified position in this vector.
|
int |
hashCode()
Returns the hash code value for this vector.
|
int |
indexOf(int element)
Returns the index in this vector of the first occurrence of the specified
element, or -1 if this vector does not contain this element.
|
boolean |
isEmpty()
Returns true if this vector contains no elements.
|
IntIterator |
iterator()
Returns an iterator over the elements in this vector in proper sequence.
|
IntIterator |
iterator(int fromIndex,
int toIndex)
Returns an iterator over the elements in this vector in proper sequence,
starting fromIndex<\tt>, inclusive, and ending at toIndex<\tt>, exclusive.
|
int |
lastIndexOf(int element)
Returns the index in this vector of the last occurrence of the specified
element, or -1 if this vector does not contain this element.
|
boolean |
remove(int i)
Removes the first occurrence of the given integer from this vector,
and returns true if this vector has changed as a result of the call.
|
boolean |
removeAll(IntCollection c)
Removes all of this vector's elements that are also contained in the specified
collection.
|
int |
removeAt(int index)
Removes the element at the specified position in this vector (optional
operation).
|
boolean |
retainAll(IntCollection c)
Retains only the elements in this vector that are contained in the specified
collection.
|
int |
set(int index,
int element)
Replaces the element at the specified position in this vector with the
specified element, and returns the previous element (optional operation).
|
int |
size()
Returns the number of elements in this vector.
|
int[] |
toArray()
Returns an array containing all of the elements in this vector in proper
sequence.
|
int[] |
toArray(int[] array)
Copies the components of this vector into the specified array, provided that
it is large enough, and returns it.
|
containsAll
boolean add(int element)
add
in interface IntCollection
this.length' = this.length + 1 && this.elements' = this.elements + this.length -> element
UnsupportedOperationException
- if the add method is not supported by this vector.IllegalArgumentException
- if some aspect of this element prevents it from being added to this vector.void add(int index, int element)
this.length' = this.length + 1 &&
this.elements' = { i: [0..this.length'), e: int | i < index => e = this.elements[i],
i = index => e = element, e = this.elements[i-1] }
UnsupportedOperationException
- if the add method is not
supported by this vector.IllegalArgumentException
- if some aspect of the specified
element prevents it from being added to this vector.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > length()).boolean addAll(IntCollection c)
addAll
in interface IntCollection
appends the specified elements to the end of this vector
UnsupportedOperationException
- if the add method is not
supported by this vector.IllegalArgumentException
- if some aspect of an element in the given vector
prevents it from being added to this vector.boolean addAll(int index, IntCollection c)
inserts the specified elements at the specified position in this vector
UnsupportedOperationException
- if the add method is not
supported by this vector.IllegalArgumentException
- if some aspect of an element in the specified
collection prevents it from being added to this vector.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index > length()).void clear()
clear
in interface IntCollection
this.length' = 0 && no this.elements'
UnsupportedOperationException
- if the clear method is
not supported by this vector.boolean contains(int element)
contains
in interface IntCollection
boolean equals(Object o)
int get(int index)
IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= length()).int hashCode()
Ints.superFastHash(int[])
of the elements in the vector,
taken in the ascending order of indices.
This ensures that v1.equals(v2) implies that v1.hashCode()==v2.hashCode()
for any two IntVectors v1 and v2, as required by the general contract of the Object.hashCode method.int indexOf(int element)
boolean isEmpty()
isEmpty
in interface IntCollection
IntIterator iterator()
iterator
in interface IntCollection
IntIterator iterator(int fromIndex, int toIndex)
IndexOutOfBoundsException
- fromIndex !in [0..this.length) || toIndex !in [-1..this.length]int lastIndexOf(int element)
boolean remove(int i)
remove
in interface IntCollection
removes the first occurrence of the given integer from this vector
UnsupportedOperationException
- this is an unmodifiable collectionboolean removeAll(IntCollection c)
removeAll
in interface IntCollection
removes all of this vector's elements that are also contained in the specified
collection
NullPointerException
- c = nullUnsupportedOperationException
- this is an unmodifiable collectionint removeAt(int index)
this.length' = this.length - 1 &&
this.elements' = { i: [0..this.length'), e: int | i < index => e = this.elements[i],
e = this.elements[i+1] }
UnsupportedOperationException
- if the remove method is
not supported by this vector.IndexOutOfBoundsException
- if the index is out of range (index
< 0 || index >= length()).boolean retainAll(IntCollection c)
retainAll
in interface IntCollection
retains only the elements in this vector that are contained in the specified
collection
NullPointerException
- c = nullUnsupportedOperationException
- this is an unmodifiable collectionint set(int index, int element)
this.elements' = this.elements' ++ index -> element
UnsupportedOperationException
- if the set method is not
supported by this vector.IllegalArgumentException
- if some aspect of the specified
element prevents it from being added to this vector.IndexOutOfBoundsException
- if the index is out of range
(index < 0 || index >= length()).int size()
size
in interface IntCollection
int[] toArray()
toArray
in interface IntCollection
int[] toArray(int[] array)
toArray
in interface IntCollection
array.length>=this.length => all i: [0..this.length) | array'[i] = this.elements[i]
NullPointerException
- array = null
© Emina Torlak 2005-present