public final class Vec<T> extends Object implements IVec<T>
Constructor and Description |
---|
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 a l'aide de size
pad.
|
Vec(T[] elts)
Adapter method to translate an array of int into an IVec.
|
Modifier and Type | Method and Description |
---|---|
void |
clear() |
boolean |
contains(T e) |
<E> void |
copyTo(E[] dest) |
void |
copyTo(IVec<T> copy)
Ces operations devraient se faire en temps constant.
|
T |
delete(int index)
Delete the ith element of the vector.
|
void |
ensure(int nsize) |
boolean |
equals(Object obj) |
T |
get(int index) |
void |
growTo(int newsize,
T pad) |
int |
hashCode() |
int |
indexOf(T element) |
void |
insertFirst(T elem)
Insert an element at the very beginning 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)
Remove an element that belongs to the Vector.
|
void |
set(int index,
T elem) |
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) |
T[] |
toArray()
Allow to access the internal representation of the vector as an array.
|
String |
toString() |
void |
unsafePush(T elem)
To push an element in the vector when you know you have space for it.
|
public Vec()
public Vec(T[] elts)
elts
- a filled array of T.public Vec(int size)
size
- the capacity of the vector.public Vec(int size, T pad)
size
- la taille du vecteurpad
- l'objet servant a remplir le vecteurpublic int size()
public void shrink(int nofelems)
public void shrinkTo(int newsize)
public void pop()
public void unsafePush(T elem)
IVec
unsafePush
in interface IVec<T>
public void insertFirst(T elem)
insertFirst
in interface IVec<T>
elem
- the element to put first in the vector.public void insertFirstWithShifting(T elem)
insertFirstWithShifting
in interface IVec<T>
public T last()
public void remove(T elem)
public T delete(int index)
public void copyTo(IVec<T> copy)
public void moveTo(IVec<T> dest)
IVec
public void moveTo(int dest, int source)
IVec
vec[dest] = vec[source]
public T[] toArray()
IVec
public void sort(Comparator<T> comparator)
public void sortUnique(Comparator<T> cmp)
sortUnique
in interface IVec<T>
public boolean isEmpty()
IVec
public boolean contains(T e)
Copyright © 2013 Centre de Recherche en Informatique de Lens (CRIL). All Rights Reserved.