|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectkodkod.util.ints.AbstractIntCollection
kodkod.util.ints.AbstractIntVector
kodkod.util.ints.ArrayIntVector
public final class ArrayIntVector
A mutable implementation of the IntVector interface. Implements all optional IntVector operations. In addition to implementing the IntVector interface, this class provides methods to manipulate the size of the array that is used internally to store the elements of the IntVector.
The size, isEmpty, get, set, and iterator operations run in constant time. The insert operations run in amortized constant time, that is, adding n elements requires O(n) time. All of the other operations run in linear time (roughly speaking).
Each MutableIntVector instance has a capacity. The capacity is the size of the array used to store the elements in the list. It is always at least as large as the list size. As elements are added to a MutableIntVector, its capacity grows automatically. The details of the growth policy are not specified beyond the fact that adding an element has constant amortized time cost.
An application can increase the capacity of an MutableIntVector instance before adding a large number of elements using the ensureCapacity operation. This may reduce the amount of incremental reallocation.
This impementation is not synchronized and its iterators are not fail-fast.
Constructor Summary | |
---|---|
ArrayIntVector()
Constructs an empty MutableIntVector with an initial capacity of ten. |
|
ArrayIntVector(int initialCapacity)
Constructs an empty MutableIntVector with the specified initial capacity. |
|
ArrayIntVector(int[] array)
Constructs a MutableIntVector containing the elements of the specified array, in proper sequence. |
Method Summary | |
---|---|
boolean |
add(int element)
Calls this.add(this.size(), element) |
void |
add(int index,
int element)
Throws UnsupportedOperationException |
boolean |
addAll(int index,
IntCollection c)
Throws an UnsupportedOperationException. |
void |
ensureCapacity(int minCapacity)
Increases the capacity of this MutableIntVector instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument. |
int |
get(int index)
Returns the element at the specified position in this vector. |
int |
removeAt(int index)
Throws an UnsupportedOperationException. |
int |
set(int index,
int element)
Throws UnsupportedOperationException . |
int |
size()
Returns the number of elements in this collection. |
int[] |
toArray(int[] array)
Copies the elements of this collection into the specified array, provided that it is large enough, and returns it. If the array is not large enough, the effect of this method is the same as calling IntCollection.toArray(). |
void |
trimToSize()
Trims the capacity of this MutableIntVector instance to be the list's current size. |
Methods inherited from class kodkod.util.ints.AbstractIntVector |
---|
addAll, contains, equals, hashCode, indexOf, iterator, iterator, lastIndexOf, toString |
Methods inherited from class kodkod.util.ints.AbstractIntCollection |
---|
clear, containsAll, isEmpty, remove, removeAll, retainAll, toArray |
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface kodkod.util.ints.IntVector |
---|
clear, isEmpty, remove, removeAll, retainAll, toArray |
Methods inherited from interface kodkod.util.ints.IntCollection |
---|
containsAll |
Constructor Detail |
---|
public ArrayIntVector(int initialCapacity)
java.lang.IllegalArgumentException
- if the specified initial capacity
is negativepublic ArrayIntVector()
public ArrayIntVector(int[] array)
java.lang.NullPointerException
- if the specified array is null.Method Detail |
---|
public void trimToSize()
public void ensureCapacity(int minCapacity)
public int get(int index)
IntVector.get(int)
public int size()
IntVector.size()
public int set(int index, int element)
UnsupportedOperationException
.
set
in interface IntVector
set
in class AbstractIntVector
IntVector.set(int, int)
public boolean add(int element)
add
in interface IntCollection
add
in interface IntVector
add
in class AbstractIntVector
IntVector.add(int)
public void add(int index, int element)
UnsupportedOperationException
add
in interface IntVector
add
in class AbstractIntVector
IntVector.add(int, int)
public boolean addAll(int index, IntCollection c)
addAll
in interface IntVector
addAll
in class AbstractIntVector
IntVector.addAll(int, kodkod.util.ints.IntCollection)
public int removeAt(int index)
removeAt
in interface IntVector
removeAt
in class AbstractIntVector
AbstractIntVector.removeAt(int)
public int[] toArray(int[] array)
toArray
in interface IntCollection
toArray
in interface IntVector
toArray
in class AbstractIntCollection
AbstractIntCollection.toArray(int[])
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |