Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/data/Vector.h>
Classes | |
class | Iter |
Public Types | |
typedef T | t |
typedef Vector< T, E, A > | self_t |
Public Types inherited from Equiv< T > | |
typedef T | t |
Public Member Functions | |
Vector (int _cap=8) | |
Vector (const Vector< T > &vec) | |
~Vector (void) | |
const E & | equivalence () const |
E & | equivalence () |
const A & | allocator () const |
A & | allocator () |
int | capacity (void) const |
Array< const T > | asArray (void) const |
Array< T > | asArray (void) |
Array< T > | detach (void) |
void | grow (int new_cap) |
void | setLength (int new_length) |
T & | addNew (void) |
int | count (void) const |
bool | contains (const T &v) const |
template<class C > | |
bool | containsAll (const C &items) |
bool | isEmpty (void) const |
operator bool (void) const | |
Iter | begin (void) const |
Iter | end (void) const |
template<class C > | |
bool | equals (const C &c) const |
bool | operator== (const Vector< T > &v) const |
bool | operator!= (const Vector< T > &v) const |
void | clear (void) |
void | add (const T &v) |
template<class C > | |
void | addAll (const C &c) |
void | remove (const T &value) |
template<class C > | |
void | removeAll (const C &c) |
void | remove (const Iter &i) |
Vector< T > & | operator+= (const T x) |
Vector< T > & | operator-= (const T x) |
void | copy (const Vector &vec) |
Vector< T > & | operator= (const Vector &vec) |
int | length (void) const |
const T & | get (int i) const |
int | indexOf (const T &v, int p=0) const |
int | lastIndexOf (const T &v, int p=-1) const |
const T & | operator[] (int i) const |
void | shrink (int l) |
void | set (int i, const T &v) |
void | set (const Iter &i, const T &v) |
T & | get (int index) |
T & | get (const Iter &i) |
T & | operator[] (int i) |
T & | operator[] (const Iter &i) |
void | insert (int i, const T &v) |
void | insert (const Iter &i, const T &v) |
void | removeAt (int i) |
void | removeAt (const Iter &i) |
const T & | first (void) const |
const T & | last (void) const |
Iter | find (const T &v) const |
Iter | find (const T &v, const Iter &p) const |
const T & | nth (int i) const |
T & | first () |
T & | last () |
void | addFirst (const T &v) |
void | addLast (const T &v) |
void | removeFirst (void) |
void | removeLast (void) |
void | addAfter (const Iter &i, const T &v) |
void | addBefore (const Iter &i, const T &v) |
void | removeBefore (const Iter &i) |
void | removeAfter (const Iter &i) |
const T & | top (void) const |
T & | top (void) |
T | pop (void) |
void | push (const T &v) |
void | reset (void) |
Iter | operator* (void) const |
Iter | items (void) const |
Public Member Functions inherited from Equiv< T > | |
bool | isEqual (const T &v1, const T &v2) const |
Public Member Functions inherited from DefaultAllocatorDelegate | |
t::ptr | allocate (t::size size) const |
void | free (t::ptr p) const |
template<class T > | |
T * | alloc () const |
Static Public Attributes | |
static const Vector< T, E, A > | null |
Static Public Attributes inherited from Equiv< T > | |
static Equiv< T > | def |
Additional Inherited Members | |
Static Public Member Functions inherited from Equiv< T > | |
static bool | equals (const T &v1, const T &v2) |
This class provides a generic implementation of an extensible vector. It provides fast access to its content using indexes but the addition of new elements may be expensive if the number of elements exceeds the capacity. Therefore, it more efficient with a small number of elements. For bigger arrays, see FragTable.
T | Type of data stored in the list. |
M | Manager supporting equivalence and allocation. |
typedef T t |
|
inline |
Build a new vector.
_cap | Capacity represents the initial and growing size of the fector. |
Build a vector by copying an existing one.
vec | Vector to copy. |
|
inline |
Add a value to the end of the vector, extending it if required.
value | Value to add. |
Referenced by AbstractBlockAllocatorWithGC::AbstractBlockAllocatorWithGC(), ListOption< T >::add(), Vector< elm::dtd::AbstractAttribute * >::addAll(), ProcessBuilder::addArgument(), Vector< elm::dtd::AbstractAttribute * >::addLast(), Plugin::make::alias(), AbstractBlockAllocatorWithGC::allocate(), Nodes::append(), Option::Make::cmd(), Manager::displayHelp(), AbstractClass::downCast(), Nodes::Nodes(), Vector< elm::dtd::AbstractAttribute * >::operator+=(), Manager::parse(), StringList::process(), ListOption< T >::process(), ProcessBuilder::ProcessBuilder(), Vector< elm::dtd::AbstractAttribute * >::push(), and Tuple1< T, A >::split().
|
inline |
Referenced by Nodes::operator=(), and Plugin::Plugin().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Return the vector as an array.
Return the vector as an array.
Referenced by Bag< T >::make().
Referenced by ListOption< T >::begin().
|
inline |
Get the capacity of the vector.
Get the capacity of the vector.
Remove all items from the vector.
Referenced by Nodes::operator=(), and Vector< elm::dtd::AbstractAttribute * >::reset().
|
inline |
Test if the given value is already in the vector.
value | Value to look for. |
Referenced by Nodes::contains(), Vector< elm::dtd::AbstractAttribute * >::containsAll(), and Manager::displayHelp().
|
inline |
Copy the given vector into the current one.
vec | Vector to copy. |
Copy the given vector in the current one.
vec | Vector to copy. |
Referenced by Vector< elm::dtd::AbstractAttribute * >::operator=(), and Vector< elm::dtd::AbstractAttribute * >::Vector().
|
inline |
Referenced by Vector< elm::dtd::AbstractAttribute * >::asArray(), ListOption< T >::count(), StringList::count(), AbstractClass::downCast(), Vector< elm::dtd::AbstractAttribute * >::end(), Vector< elm::dtd::AbstractAttribute * >::equals(), Vector< elm::dtd::AbstractAttribute * >::length(), AbstractBlockAllocatorWithGC::mark(), ProcessBuilder::run(), Nodes::size(), and AbstractBlockAllocatorWithGC::~AbstractBlockAllocatorWithGC().
Detach the buffer from the vector and return it as a table. After this call, the vector stays unusable until a setLength() or a grow() is performed.
Referenced by Plugin::Plugin().
Referenced by ListOption< T >::end().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Referenced by Vector< elm::dtd::AbstractAttribute * >::get().
|
inline |
Get an item from the vector.
index | Index of the item to get. |
Referenced by Vector< elm::dtd::AbstractAttribute * >::nth(), and Vector< elm::dtd::AbstractAttribute * >::operator[]().
|
inline |
|
inline |
Make the capacity of the vector to grow, possibly causing a buffer re-allocation. Notice that the length is unchanged.
new_cap | New capacity of the vector. |
Enlarge the vector with the given capacity.
new_cap | Size for enlarging the vector. |
Referenced by Vector< elm::dtd::AbstractAttribute * >::add(), Vector< elm::dtd::AbstractAttribute * >::addNew(), Vector< elm::dtd::AbstractAttribute * >::insert(), and Vector< elm::dtd::AbstractAttribute * >::setLength().
|
inline |
Compute the first index of the value in the vector.
value | Value to look for. |
start | Start index for looking the value for. |
Referenced by Plugger::Plugger(), and Vector< elm::dtd::AbstractAttribute * >::remove().
Referenced by Vector< elm::dtd::AbstractAttribute * >::insert().
|
inline |
Test if vector is empty.
Referenced by ListOption< T >::operator bool().
|
inline |
|
inline |
Referenced by Vector< elm::dtd::AbstractAttribute * >::top().
|
inline |
Compute the last index of the value in the vector.
value | Value to look for. |
start | Start index for looking the value for. |
|
inline |
Get the number of items in the vector.
Referenced by Vector< T, E, A >::Iter::ended(), and AbstractBlockAllocatorWithGC::totalCount().
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Same as item(int).
|
inline |
Same as item(int) const.
|
inline |
Pop an item from the end of the vector and shrink its length by 1.
Referenced by XOMElementSerializer::endCompound(), XOMElementSerializer::endField(), XOMUnserializer::endField(), Saver::endList(), Saver::endMap(), TreeBag< T, C, A >::Iter::next(), XOMUnserializer::nextItem(), XOMElementSerializer::onItem(), Saver::put(), and Saver::write().
|
inline |
Push an item at the end of the vector..
value | Value to push in. @seealso add() |
Referenced by XOMElementSerializer::beginCompound(), XOMUnserializer::beginCompound(), XOMElementSerializer::beginField(), XOMUnserializer::beginField(), Saver::beginList(), Saver::beginMap(), Saver::key(), XOMUnserializer::nextItem(), and XOMElementSerializer::onItem().
|
inline |
|
inline |
Referenced by Vector< elm::dtd::AbstractAttribute * >::removeAt().
|
inline |
Remove the value at the given index. Values past the index are shifted to the left.
index | Index of the value to remove. |
Referenced by ListOption< T >::remove(), Vector< elm::dtd::AbstractAttribute * >::remove(), Vector< elm::dtd::AbstractAttribute * >::removeAfter(), Vector< elm::dtd::AbstractAttribute * >::removeBefore(), Vector< elm::dtd::AbstractAttribute * >::removeFirst(), and Vector< elm::dtd::AbstractAttribute * >::removeLast().
Referenced by Vector< elm::dtd::AbstractAttribute * >::set().
|
inline |
|
inline |
Change the length of the vector, possibly causing re-allocation of the buffer.
new_length | New length of the vector. |
Set the length of the vector.
new_length | New length of the vector (must be less or equal to the current length of the vector). |
|
inline |
|
inline |
Get the last item of the vector, that is, the top of the stack represented by the vector.
|
inline |
|
static |