Package org.jacop.jasat.utils.structures
Class IntVec
- java.lang.Object
-
- org.jacop.jasat.utils.structures.IntVec
-
- All Implemented Interfaces:
java.lang.Iterable<java.lang.Integer>
public final class IntVec extends java.lang.Object implements java.lang.Iterable<java.lang.Integer>
low level, efficient int vector- Version:
- 4.7
-
-
Field Summary
Fields Modifier and Type Field Description int[]
array
int
numElem
MemoryPool
pool
-
Constructor Summary
Constructors Constructor Description IntVec(MemoryPool pool)
initializes the array with a memory poolIntVec(MemoryPool pool, java.lang.Iterable<java.lang.Integer> clause)
initialize from pool and some integers
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
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 elementsjava.util.Iterator<java.lang.Integer>
iterator()
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 clausejava.lang.String
toString()
-
-
-
Field Detail
-
array
public int[] array
-
numElem
public int numElem
-
pool
public MemoryPool pool
-
-
Constructor Detail
-
IntVec
public IntVec(MemoryPool pool)
initializes the array with a memory pool- Parameters:
pool
- the pool to use for memory allocation
-
IntVec
public IntVec(MemoryPool pool, java.lang.Iterable<java.lang.Integer> clause)
initialize from pool and some integers- Parameters:
pool
- the pool to useclause
- the elements to add
-
-
Method Detail
-
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
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
iterator
public java.util.Iterator<java.lang.Integer> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<java.lang.Integer>
-
-