org.sat4j.core
Class VecInt

java.lang.Object
  extended by org.sat4j.core.VecInt
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<java.lang.Integer>, IVecInt

public class VecInt
extends java.lang.Object
implements java.io.Serializable, IVecInt

A vector specific for primitive integers, widely used in the solver.

Author:
leberre
See Also:
Serialized Form

Field Summary
static IVecInt EMPTY
           
 
Constructor Summary
VecInt()
           
VecInt(int size)
           
VecInt(int[] lits)
          Adapter method to translate an array of int into an IVecInt.
VecInt(int size, int pad)
          Build a vector of a given initial size filled with an integer.
 
Method Summary
 void clear()
           
 boolean contains(int e)
           
 void copyTo(int[] is)
           
 void copyTo(IVecInt copy)
          C'est op�rations devraient se faire en temps constant.
 int delete(int i)
          Delete the ith element of the vector.
 void ensure(int nsize)
           
 boolean equals(java.lang.Object obj)
           
 int get(int i)
           
 void growTo(int newsize, int pad)
           
 int hashCode()
           
 void insertFirst(int elem)
          Insert an element at the very begining of the vector.
 boolean isEmpty()
          To know if a vector is empty
 boolean isSubsetOf(IVecInt vec)
           
 java.util.Iterator<java.lang.Integer> iterator()
           
 int last()
           
 void moveTo(int[] dest)
           
 void moveTo(int dest, int source)
          Move elements inside the vector.
 void moveTo(IVecInt dest)
           
 void moveTo2(IVecInt dest)
           
 IVecInt pop()
          d�pile le dernier �l�ment du vecteur.
 IVecInt push(int elem)
           
 void pushAll(IVecInt vec)
           
 void remove(int elem)
          Enleve un element qui se trouve dans le vecteur!!!
 void set(int i, int o)
           
 void shrink(int nofelems)
          Remove the latest nofelems elements from the vector
 void shrinkTo(int newsize)
           
 int size()
           
 void sort()
          sort the vector using a custom quicksort.
 void sortUnique()
           
 java.lang.String toString()
           
 int unsafeGet(int i)
           
 void unsafePush(int elem)
          Push the element in the Vector without verifying if there is room for it.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final IVecInt EMPTY
Constructor Detail

VecInt

public VecInt()

VecInt

public VecInt(int size)

VecInt

public VecInt(int[] lits)
Adapter method to translate an array of int into an IVecInt. The array is used inside the VecInt, so the elements may be modified outside the VecInt. But it should not take much memory.The size of the created VecInt is the length of the array.

Parameters:
lits - a filled array of int.

VecInt

public VecInt(int size,
              int pad)
Build a vector of a given initial size filled with an integer.

Parameters:
size - the initial size of the vector
pad - the integer to fill the vector with
Method Detail

size

public int size()
Specified by:
size in interface IVecInt

shrink

public void shrink(int nofelems)
Remove the latest nofelems elements from the vector

Specified by:
shrink in interface IVecInt
Parameters:
nofelems -

shrinkTo

public void shrinkTo(int newsize)
Specified by:
shrinkTo in interface IVecInt

pop

public IVecInt pop()
d�pile le dernier �l�ment du vecteur. Si le vecteur est vide, ne fait rien.

Specified by:
pop in interface IVecInt

growTo

public void growTo(int newsize,
                   int pad)
Specified by:
growTo in interface IVecInt

ensure

public void ensure(int nsize)
Specified by:
ensure in interface IVecInt

push

public IVecInt push(int elem)
Specified by:
push in interface IVecInt

unsafePush

public void unsafePush(int elem)
Description copied from interface: IVecInt
Push the element in the Vector without verifying if there is room for it. USE WITH CAUTION!

Specified by:
unsafePush in interface IVecInt

clear

public void clear()
Specified by:
clear in interface IVecInt

last

public int last()
Specified by:
last in interface IVecInt

get

public int get(int i)
Specified by:
get in interface IVecInt

unsafeGet

public int unsafeGet(int i)
Specified by:
unsafeGet in interface IVecInt

set

public void set(int i,
                int o)
Specified by:
set in interface IVecInt

contains

public boolean contains(int e)
Specified by:
contains in interface IVecInt

copyTo

public void copyTo(IVecInt copy)
C'est op�rations devraient se faire en temps constant. Ce n'est pas le cas ici.

Specified by:
copyTo in interface IVecInt
Parameters:
copy -

copyTo

public void copyTo(int[] is)
Specified by:
copyTo in interface IVecInt
Parameters:
is -

moveTo

public void moveTo(IVecInt dest)
Specified by:
moveTo in interface IVecInt

moveTo2

public void moveTo2(IVecInt dest)
Specified by:
moveTo2 in interface IVecInt

moveTo

public void moveTo(int dest,
                   int source)
Description copied from interface: IVecInt
Move elements inside the vector. The content of the method is equivalent to: vec[dest] = vec[source]

Specified by:
moveTo in interface IVecInt
Parameters:
dest - the index of the destination
source - the index of the source

moveTo

public void moveTo(int[] dest)
Specified by:
moveTo in interface IVecInt

insertFirst

public void insertFirst(int 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.

Specified by:
insertFirst in interface IVecInt
Parameters:
elem - the element to put first in the vector.

remove

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

Specified by:
remove in interface IVecInt
Parameters:
elem - un element du vecteur

delete

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

Specified by:
delete in interface IVecInt
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 java.lang.String toString()
Overrides:
toString in class java.lang.Object

sort

public void sort()
sort the vector using a custom quicksort.

Specified by:
sort in interface IVecInt

sortUnique

public void sortUnique()
Specified by:
sortUnique in interface IVecInt

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

pushAll

public void pushAll(IVecInt vec)

isSubsetOf

public boolean isSubsetOf(IVecInt vec)

iterator

public java.util.Iterator<java.lang.Integer> iterator()
Specified by:
iterator in interface java.lang.Iterable<java.lang.Integer>

isEmpty

public boolean isEmpty()
Description copied from interface: IVecInt
To know if a vector is empty

Specified by:
isEmpty in interface IVecInt
Returns:
true iff the vector is empty.