org.sat4j.specs
Interface IVec<T>

All Superinterfaces:
Serializable
All Known Implementing Classes:
ReadOnlyVec, Vec

public interface IVec<T>
extends Serializable

An abstraction on the type of vector used in the library.

Author:
leberre

Method Summary
 void clear()
           
 boolean contains(T element)
           
<E> void
copyTo(E[] dest)
           
 void copyTo(IVec<T> copy)
          Ces operations devraient se faire en temps constant.
 T delete(int i)
          Delete the ith element of the vector.
 void ensure(int nsize)
           
 T get(int i)
           
 void growTo(int newsize, T pad)
           
 int indexOf(T element)
           
 void insertFirst(T elem)
          Insert an element at the very begining of the vector.
 void insertFirstWithShifting(T elem)
           
 boolean isEmpty()
          To know if a vector is empty
 Iterator<T> iterator()
           
 T last()
          return the latest element on the stack.
 void moveTo(int dest, int source)
          Move elements inside the vector.
 void moveTo(IVec<T> dest)
          Move the content of the vector into dest.
 void pop()
          Pop the last element on the stack.
 IVec<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> comparator)
           
 T[] toArray()
          Allow to access the internal representation of the vector as an array.
 void unsafePush(T elem)
          To push an element in the vector when you know you have space for it.
 

Method Detail

size

int size()
Returns:
the number of elements contained in the vector

shrink

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

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

Parameters:
newsize - the new size of the vector.

pop

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


growTo

void growTo(int newsize,
            T pad)

ensure

void ensure(int nsize)

push

IVec<T> push(T elem)

unsafePush

void unsafePush(T elem)
To push an element in the vector when you know you have space for it.

Parameters:
elem -

insertFirst

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

void insertFirstWithShifting(T elem)

clear

void clear()

last

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

Returns:
the last (top) element on the stack

get

T get(int i)

set

void set(int i,
         T o)

remove

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

Parameters:
elem - un element du vecteur

delete

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

copyTo

void copyTo(IVec<T> copy)
Ces operations devraient se faire en temps constant. Ce n'est pas le cas ici.

Parameters:
copy -

copyTo

<E> void copyTo(E[] dest)

toArray

T[] toArray()
Allow to access the internal representation of the vector as an array. Note that only the content of index 0 to size() should be taken into account. USE WITH CAUTION

Returns:
the internal representation of the Vector as an array.

moveTo

void moveTo(IVec<T> dest)
Move the content of the vector into dest. Note that the vector become empty. The content of the vector is appended to dest.

Parameters:
dest - the vector where top put the content of this vector

moveTo

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

Parameters:
dest - the index of the destination
source - the index of the source

sort

void sort(Comparator<T> comparator)

sortUnique

void sortUnique(Comparator<T> comparator)

isEmpty

boolean isEmpty()
To know if a vector is empty

Returns:
true iff the vector is empty.
Since:
1.6

iterator

Iterator<T> iterator()

contains

boolean contains(T element)
Parameters:
element - an object
Returns:
true iff element is found in the vector.
Since:
2.1

indexOf

int indexOf(T element)
Parameters:
element - an object
Returns:
the index of the element if it is found in the vector, else -1.
Since:
2.2


Copyright © 2011 Centre de Recherche en Informatique de Lens (CRIL). All Rights Reserved.