Elm
1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/genstruct/Vector.h>
Classes | |
class | Iterator |
Public Member Functions | |
Vector (int _cap=8) | |
Vector (const Vector< T > &vec) | |
~Vector (void) | |
int | count (void) const |
int | length (void) const |
int | capacity (void) const |
bool | isEmpty (void) const |
const T & | get (int index) const |
T & | item (int index) |
void | set (int index, const T value) |
T & | operator[] (int index) |
const T & | operator[] (int index) const |
bool | contains (const T &value) const |
template<template< class _ > class C> | |
bool | containsAll (const C< T > &items) |
int | indexOf (const T &value, int start=0) const |
int | lastIndexOf (const T &value, int start=-1) const |
operator bool (void) const | |
bool | operator== (const Vector< T > &v) const |
bool | operator!= (const Vector< T > &v) const |
const T & | first (void) const |
const T & | last (void) const |
Iterator | find (const T &item) |
Iterator | find (const T &item, const Iterator &start) |
const T & | top (void) const |
void | add (void) |
void | add (const T &value) |
template<template< class _ > class C> | |
void | addAll (const C< T > &items) |
void | removeAt (int index) |
void | remove (const T &value) |
void | remove (const Iterator &iter) |
template<template< class _ > class C> | |
void | removeAll (const C< T > &items) |
void | insert (int index, const T &value) |
void | clear (void) |
void | grow (int new_cap) |
void | setLength (int new_length) |
table< T > | detach (void) |
void | copy (const Vector &vec) |
Vector< T > & | operator= (const Vector &vec) |
void | swallow (Vector< T > &v) |
void | insert (const T &item) |
void | push (const T &value) |
const T | pop (void) |
void | addFirst (const T &item) |
void | addLast (const T &item) |
void | removeFirst (void) |
void | removeLast (void) |
void | set (const Iterator &pos, const T &item) |
void | addAfter (const Iterator &pos, const T &item) |
void | addBefore (const Iterator &pos, const T &item) |
A vector is an array of items whose size grows dynamically.
T | Type of stored items. |
elm::genstruct::Vector< T >::Vector | ( | int | _cap = 8 | ) |
Build a new vector.
_cap | Capacity represents the initial and growing size of the fector. |
elm::genstruct::Vector< T >::Vector | ( | const Vector< T > & | vec | ) |
Build a vector by copying an existing one.
vec | Vector to copy. |
elm::genstruct::Vector< T >::~Vector | ( | void | ) |
Delete the vector and all its contained items.
void elm::genstruct::Vector< T >::add | ( | void | ) |
Referenced by elm::AbstractBlockAllocatorWithGC::AbstractBlockAllocatorWithGC(), elm::genstruct::Vector< elm::xom::Node * >::addAll(), elm::genstruct::Vector< elm::xom::Node * >::addLast(), elm::AbstractBlockAllocatorWithGC::allocate(), elm::xom::Nodes::append(), elm::ini::Section::getList(), elm::genstruct::Vector< elm::xom::Node * >::insert(), elm::xom::Nodes::Nodes(), and elm::genstruct::Vector< elm::xom::Node * >::push().
void elm::genstruct::Vector< T >::add | ( | const T & | value | ) |
References elm::value().
void elm::genstruct::Vector< T >::addAfter | ( | const Iterator & | pos, |
const T & | item | ||
) |
void elm::genstruct::Vector< T >::addAll | ( | const C< T > & | items | ) |
Referenced by elm::xom::Nodes::operator=(), and elm::sys::Plugin::Plugin().
void elm::genstruct::Vector< T >::addBefore | ( | const Iterator & | pos, |
const T & | item | ||
) |
void elm::genstruct::Vector< T >::addFirst | ( | const T & | item | ) |
void elm::genstruct::Vector< T >::addLast | ( | const T & | item | ) |
int elm::genstruct::Vector< T >::capacity | ( | void | ) | const |
Get the capacity of the vector.
void elm::genstruct::Vector< T >::clear | ( | void | ) |
Remove all items from the vector.
Referenced by elm::xom::Nodes::operator=().
bool elm::genstruct::Vector< T >::contains | ( | const T & | value | ) | const |
Test if the given value is already in the vector.
value | Value to look for. |
Referenced by elm::xom::Nodes::contains(), and elm::genstruct::Vector< elm::xom::Node * >::containsAll().
bool elm::genstruct::Vector< T >::containsAll | ( | const C< T > & | items | ) |
void elm::genstruct::Vector< T >::copy | ( | const Vector< T > & | vec | ) |
Copy the given vector in the current one.
vec | Vector to copy. |
Referenced by elm::genstruct::Vector< elm::xom::Node * >::operator=(), and elm::genstruct::Vector< elm::xom::Node * >::Vector().
int elm::genstruct::Vector< T >::count | ( | void | ) | const |
Referenced by elm::AbstractBlockAllocatorWithGC::collectGarbage(), elm::genstruct::FragTable< T >::isEmpty(), elm::genstruct::Vector< elm::xom::Node * >::length(), elm::AbstractBlockAllocatorWithGC::mark(), elm::xom::Nodes::size(), and elm::AbstractBlockAllocatorWithGC::~AbstractBlockAllocatorWithGC().
table< T > elm::genstruct::Vector< T >::detach | ( | void | ) |
Referenced by elm::sys::Plugin::Plugin().
Iterator elm::genstruct::Vector< T >::find | ( | const T & | item | ) |
Iterator elm::genstruct::Vector< T >::find | ( | const T & | item, |
const Iterator & | start | ||
) |
const T& elm::genstruct::Vector< T >::first | ( | void | ) | const |
T elm::genstruct::Vector< T >::get | ( | int | index | ) | const |
Get an item from the vector.
index | Index of the item to get. |
void elm::genstruct::Vector< T >::grow | ( | int | new_cap | ) |
Enlarge the vector with the given capacity.
new_cap | Size for enlarging the vector. |
int elm::genstruct::Vector< T >::indexOf | ( | const T & | value, |
int | start = 0 |
||
) | const |
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 elm::genstruct::Vector< elm::xom::Node * >::remove().
void elm::genstruct::Vector< T >::insert | ( | int | index, |
const T & | value | ||
) |
void elm::genstruct::Vector< T >::insert | ( | const T & | item | ) |
bool elm::genstruct::Vector< T >::isEmpty | ( | void | ) | const |
Test if vector is empty.
T & elm::genstruct::Vector< T >::item | ( | int | index | ) |
Get a reference to an item in the vector, allowing to change the item.
index | Index of the item to get. |
Referenced by elm::genstruct::Vector< elm::xom::Node * >::addAll(), elm::genstruct::Vector< elm::xom::Node * >::containsAll(), elm::genstruct::Vector< elm::xom::Node * >::operator[](), elm::genstruct::Vector< elm::xom::Node * >::removeAll(), and elm::genstruct::Vector< elm::xom::Node * >::set().
const T& elm::genstruct::Vector< T >::last | ( | void | ) | const |
int elm::genstruct::Vector< T >::lastIndexOf | ( | const T & | value, |
int | start = -1 |
||
) | const |
Compute the last index of the value in the vector.
value | Value to look for. |
start | Start index for looking the value for. |
int elm::genstruct::Vector< T >::length | ( | void | ) | const |
Get the number of items in the vector.
Referenced by elm::genstruct::Vector< elm::xom::Node * >::operator==(), and elm::AbstractBlockAllocatorWithGC::totalCount().
elm::genstruct::Vector< T >::operator bool | ( | void | ) | const |
Same as isEmpty().
bool elm::genstruct::Vector< T >::operator!= | ( | const Vector< T > & | v | ) | const |
Vector< T > & elm::genstruct::Vector< T >::operator= | ( | const Vector< T > & | vec | ) |
Shortcut to copy().
bool elm::genstruct::Vector< T >::operator== | ( | const Vector< T > & | v | ) | const |
T & elm::genstruct::Vector< T >::operator[] | ( | int | index | ) |
Same as item(int).
T elm::genstruct::Vector< T >::operator[] | ( | int | index | ) | const |
Same as item(int) const.
const T elm::genstruct::Vector< T >::pop | ( | void | ) |
Pop an item from the end of the vector and shrink its length by 1.
Referenced by elm::avl::AbstractTree::count(), elm::serial2::XOMSerializer::endCompound(), elm::serial2::XOMUnserializer::endField(), elm::serial2::XOMSerializer::endField(), elm::serial::XOMUnserializer::endField(), elm::serial2::XOMUnserializer::flush(), elm::genstruct::GenSortedBinTree< T, K, C >::Iterator::next(), elm::serial2::XOMUnserializer::nextItem(), elm::serial::XOMUnserializer::nextItem(), and elm::serial2::XOMSerializer::onItem().
void elm::genstruct::Vector< T >::push | ( | const T & | value | ) |
Push an item at the end of the vector..
value | Value to push in. add() |
Referenced by elm::serial2::XOMUnserializer::beginCompound(), elm::serial2::XOMSerializer::beginCompound(), elm::serial2::XOMUnserializer::beginField(), elm::serial2::XOMSerializer::beginField(), elm::serial::XOMUnserializer::beginField(), elm::serial::XOMUnserializer::beginList(), elm::avl::AbstractTree::count(), elm::serial2::XOMUnserializer::flush(), elm::genstruct::GenSortedBinTree< T, K, C >::Iterator::Iterator(), elm::genstruct::GenSortedBinTree< T, K, C >::Iterator::next(), elm::serial2::XOMUnserializer::nextItem(), elm::serial::XOMUnserializer::nextItem(), and elm::serial2::XOMSerializer::onItem().
void elm::genstruct::Vector< T >::remove | ( | const T & | value | ) |
Referenced by elm::xom::Nodes::remove().
void elm::genstruct::Vector< T >::remove | ( | const Iterator & | iter | ) |
void elm::genstruct::Vector< T >::removeAll | ( | const C< T > & | items | ) |
void elm::genstruct::Vector< T >::removeAt | ( | int | index | ) |
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 elm::genstruct::Vector< elm::xom::Node * >::remove(), elm::genstruct::Vector< elm::xom::Node * >::removeFirst(), and elm::genstruct::Vector< elm::xom::Node * >::removeLast().
void elm::genstruct::Vector< T >::removeFirst | ( | void | ) |
void elm::genstruct::Vector< T >::removeLast | ( | void | ) |
void elm::genstruct::Vector< T >::set | ( | int | index, |
const T | value | ||
) |
Change the value of the item at the given index.
index | Index of item to set. |
value | Value to replace the item. |
References elm::value().
void elm::genstruct::Vector< T >::set | ( | const Iterator & | pos, |
const T & | item | ||
) |
void elm::genstruct::Vector< T >::setLength | ( | int | new_length | ) |
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). |
void elm::genstruct::Vector< T >::swallow | ( | Vector< T > & | v | ) |
const T elm::genstruct::Vector< T >::top | ( | void | ) | const |
Get the last item of the vector, that is, the top of the stack represented by the vector.
Referenced by elm::AbstractBlockAllocatorWithGC::AbstractBlockAllocatorWithGC(), elm::AbstractBlockAllocatorWithGC::allocate(), elm::genstruct::GenSortedBinTree< T, K, C >::Iterator::item(), and elm::AbstractBlockAllocatorWithGC::totalCount().