choco.cp.solver.constraints.integer.bool.sat
Class Vec<T>

java.lang.Object
  extended by choco.cp.solver.constraints.integer.bool.sat.Vec<T>

public final class Vec<T>
extends Object


Constructor Summary
Vec()
          Create a Vector with an initial capacity of 5 elements.
Vec(int size)
          Create a Vector with a given capacity.
Vec(int size, T pad)
          Construit un vecteur contenant de taille size rempli ?
Vec(T[] elts)
          Adapter method to translate an array of int into an IVec.
 
Method Summary
 void clear()
           
 T delete(int i)
          Delete the ith element of the vector.
 void ensure(int nsize)
           
 boolean equals(Object obj)
           
 T get(int i)
           
 void growTo(int newsize, T pad)
           
 int hashCode()
           
 void insertFirst(T elem)
          Insert an element at the very begining of the vector.
 void insertFirstWithShifting(T elem)
           
 Iterator<T> iterator()
           
 T last()
          return the latest element on the stack.
 void pop()
          Pop the last element on the stack.
 Vec<T> push(T elem)
           
 void remove(T elem)
          Enleve un element qui se trouve dans le vecteur!!!
 void set(int i, T o)
           
 void shrink(int nofelems)
          Remove nofelems from the Vector.
 void shrinkTo(int newsize)
          reduce the Vector to exactly newsize elements
 int size()
           
 void sort(Comparator<T> comparator)
           
 void sortUnique(Comparator<T> cmp)
           
 String toString()
           
 void unsafePush(T elem)
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Vec

public Vec()
Create a Vector with an initial capacity of 5 elements.


Vec

public Vec(T[] elts)
Adapter method to translate an array of int into an IVec.

The array is used inside the Vec, so the elements may be modified outside the Vec. But it should not take much memory. The size of the created Vec is the length of the array.

Parameters:
elts - a filled array of T.

Vec

public Vec(int size)
Create a Vector with a given capacity.

Parameters:
size - the capacity of the vector.

Vec

public Vec(int size,
           T pad)
Construit un vecteur contenant de taille size rempli ? l'aide de size pad.

Parameters:
size - la taille du vecteur
pad - l'objet servant ? remplir le vecteur
Method Detail

size

public int size()

shrink

public void shrink(int nofelems)
Remove nofelems from the Vector. It is assumed that the number of elements to remove is smaller or equals to the current number of elements in the vector

Parameters:
nofelems - the number of elements to remove.

shrinkTo

public void shrinkTo(int newsize)
reduce the Vector to exactly newsize elements

Parameters:
newsize - the new size of the vector.

pop

public void pop()
Pop the last element on the stack. It is assumed that the stack is not empty!


growTo

public void growTo(int newsize,
                   T pad)

ensure

public final void ensure(int nsize)

push

public Vec<T> push(T elem)

unsafePush

public void unsafePush(T elem)

insertFirst

public void insertFirst(T elem)
Insert an element at the very begining of the vector. The former first element is appended to the end of the vector in order to have a constant time operation.

Parameters:
elem - the element to put first in the vector.

insertFirstWithShifting

public void insertFirstWithShifting(T elem)

clear

public void clear()

last

public T last()
return the latest element on the stack. It is assumed that the stack is not empty!

Returns:
the last element on the stack (the one on the top)

get

public T get(int i)

set

public void set(int i,
                T o)

remove

public void remove(T elem)
Enleve un element qui se trouve dans le vecteur!!!

Parameters:
elem - un element du vecteur

delete

public T delete(int i)
Delete the ith element of the vector. The latest element of the vector replaces the removed element at the ith indexer.

Parameters:
i - the indexer of the element in the vector
Returns:
the former ith element of the vector that is now removed from the vector

toString

public String toString()
Overrides:
toString in class Object

sort

public void sort(Comparator<T> comparator)
Parameters:
comparator -

sortUnique

public void sortUnique(Comparator<T> cmp)

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

iterator

public Iterator<T> iterator()


Copyright © 2012. All Rights Reserved.