Package org.jacop.jasat.utils.structures
Class IntVec
java.lang.Object
org.jacop.jasat.utils.structures.IntVec
low level, efficient int vector
- Version:
- 4.9
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionIntVec
(MemoryPool pool) initializes the array with a memory poolIntVec
(MemoryPool pool, Iterable<Integer> clause) initialize from pool and some integers -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(int i) add an element at the end of the arrayvoid
clear()
clears all elements in the arrayint
get
(int index) boolean
isEmpty()
checks if the array contains elementsiterator()
void
remove
(int index) remove the element at index indexvoid
removeFast
(int index) this removes the element at given index.void
set
(int index, int i) set the element at index index to iint
size()
number of elementsint[]
toArray()
get a new array from the clausetoString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
array
public int[] array -
numElem
public int numElem -
pool
-
-
Constructor Details
-
IntVec
initializes the array with a memory pool- Parameters:
pool
- the pool to use for memory allocation
-
IntVec
initialize from pool and some integers- Parameters:
pool
- the pool to useclause
- the elements to add
-
-
Method Details
-
add
public void add(int i) add an element at the end of the array- Parameters:
i
- the element to add
-
clear
public void clear()clears all elements in the array -
isEmpty
public boolean isEmpty()checks if the array contains elements- Returns:
- true if the array is empty
-
get
public int get(int index) -
set
public void set(int index, int i) set the element at index index to i- Parameters:
index
- the index to modifyi
- the new value
-
size
public int size()number of elements- Returns:
- number of elements in the vector
-
remove
public void remove(int index) remove the element at index index- Parameters:
index
- the index of the element to remove
-
removeFast
public void removeFast(int index) this removes the element at given index. This operation does *NOT* keep the order in the array (the last element may change of position)- Parameters:
index
- the index to remove
-
toArray
public int[] toArray()get a new array from the clause- Returns:
- a new array
-
toString
-
iterator
-