![]() |
Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
#include <elm/data/Vector.h>
Inheritance diagram for Vector< T, E, A >:Classes | |
| class | Iter |
| class | MutIter |
| class | PreIter |
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) |
| Iter | begin () const |
| Iter | end () const |
| 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 | |
| template<class C > | |
| bool | equals (const C &c) const |
| bool | operator== (const Vector< T > &v) const |
| bool | operator!= (const Vector< T > &v) const |
| MutIter | begin () |
| MutIter | end () |
| 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. |
References Vector< T, E, A >::copy().
|
inline |
Add a value to the end of the vector, extending it if required.
| value | Value to add. |
References Vector< T, E, A >::grow().
Referenced by AbstractBlockAllocatorWithGC::AbstractBlockAllocatorWithGC(), Nodes::Nodes(), ProcessBuilder::ProcessBuilder(), Vector< T, E, A >::addAll(), ProcessBuilder::addArgument(), Vector< T, E, A >::addLast(), Plugin::make::alias(), AbstractBlockAllocatorWithGC::allocate(), Nodes::append(), Option::Make::cmd(), Manager::displayHelp(), AbstractClass::downCast(), Vector< T, E, A >::operator+=(), Manager::parse(), StringList::process(), Vector< T, E, A >::push(), and Tuple1< T, A >::split().
References Vector< T, E, A >::PreIter::i, and Vector< T, E, A >::insert().
|
inline |
References Vector< T, E, A >::add().
Referenced by Plugin::Plugin(), and Nodes::operator=().
References Vector< T, E, A >::PreIter::i, and Vector< T, E, A >::insert().
|
inline |
References Vector< T, E, A >::insert().
|
inline |
References Vector< T, E, A >::add().
|
inline |
References Vector< T, E, A >::grow().
|
inline |
|
inline |
Return the vector as an array.
References Vector< T, E, A >::count().
Return the vector as an array.
References Vector< T, E, A >::count().
Referenced by Bag< T >::make().
|
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< T, E, A >::reset().
|
inline |
Test if the given value is already in the vector.
| value | Value to look for. |
Referenced by Nodes::contains(), Vector< T, E, A >::containsAll(), and Manager::displayHelp().
|
inline |
References Vector< T, E, A >::contains(), and Vector< T, E, A >::items().
Copy the given vector into the current one.
| vec | Vector to copy. |
Copy the given vector in the current one.
| vec | Vector to copy. |
References elm::array::copy().
Referenced by Vector< T, E, A >::Vector(), and Vector< T, E, A >::operator=().
|
inline |
Referenced by AbstractBlockAllocatorWithGC::~AbstractBlockAllocatorWithGC(), Vector< T, E, A >::asArray(), StringList::count(), AbstractClass::downCast(), Vector< T, E, A >::end(), Vector< T, E, A >::equals(), Vector< T, E, A >::length(), AbstractBlockAllocatorWithGC::mark(), ProcessBuilder::run(), and Nodes::size().
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().
References Vector< T, E, A >::count().
References Vector< T, E, A >::count().
|
inline |
References Vector< T, E, A >::count(), and elm::equals().
Referenced by Vector< T, E, A >::operator!=(), and Vector< T, E, A >::operator==().
|
inline |
|
inline |
|
inline |
References elm::equals().
References elm::equals(), and elm::io::p().
|
inline |
|
inline |
|
inline |
References Vector< T, E, A >::get(), and Vector< T, E, A >::PreIter::index().
Referenced by Vector< T, E, A >::get().
|
inline |
Get an item from the vector.
| index | Index of the item to get. |
Referenced by Vector< T, E, A >::nth(), and Vector< T, E, A >::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. |
References elm::array::copy().
Referenced by Vector< T, E, A >::add(), Vector< T, E, A >::addNew(), Vector< T, E, A >::insert(), and Vector< T, E, A >::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. |
References elm::io::p().
Referenced by Plugger::Plugger(), and Vector< T, E, A >::remove().
References Vector< T, E, A >::PreIter::i, and Vector< T, E, A >::insert().
Referenced by Vector< T, E, A >::insert().
|
inline |
References Vector< T, E, A >::grow(), and elm::array::move().
Referenced by Vector< T, E, A >::addAfter(), Vector< T, E, A >::addBefore(), Vector< T, E, A >::addFirst(), and Nodes::insert().
Test if vector is empty.
Referenced by Vector< T, E, A >::containsAll(), and Vector< T, E, A >::operator*().
|
inline |
|
inline |
Referenced by Vector< T, E, A >::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. |
References elm::io::p().
|
inline |
Get the number of items in the vector.
References Vector< T, E, A >::count().
Referenced by Vector< T, E, A >::PreIter::ended(), and AbstractBlockAllocatorWithGC::totalCount().
|
inline |
References Vector< T, E, A >::get().
References Vector< T, E, A >::equals().
References Vector< T, E, A >::items().
|
inline |
References Vector< T, E, A >::add().
|
inline |
References Vector< T, E, A >::remove().
Shortcut to copy().
References Vector< T, E, A >::copy().
References Vector< T, E, A >::equals().
|
inline |
References Vector< T, E, A >::get().
|
inline |
Same as item(int).
References Vector< T, E, A >::get().
|
inline |
Same as item(int) const.
References Vector< T, E, A >::get().
|
inline |
Pop an item from the end of the vector and shrink its length by 1.
Referenced by Parser::end(), 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() |
References Vector< T, E, A >::add().
Referenced by Parser::begin(), XOMElementSerializer::beginCompound(), XOMUnserializer::beginCompound(), XOMElementSerializer::beginField(), XOMUnserializer::beginField(), Saver::beginList(), Saver::beginMap(), Saver::key(), XOMUnserializer::nextItem(), and XOMElementSerializer::onItem().
References Vector< T, E, A >::PreIter::i, and Vector< T, E, A >::removeAt().
|
inline |
References Vector< T, E, A >::indexOf(), and Vector< T, E, A >::removeAt().
Referenced by Vector< T, E, A >::operator-=(), Nodes::remove(), and Vector< T, E, A >::removeAll().
References Vector< T, E, A >::PreIter::i, and Vector< T, E, A >::removeAt().
|
inline |
References Vector< T, E, A >::remove().
References Vector< T, E, A >::PreIter::i, and Vector< T, E, A >::removeAt().
Referenced by Vector< T, E, A >::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. |
References elm::array::move().
Referenced by Vector< T, E, A >::remove(), Vector< T, E, A >::removeAfter(), Vector< T, E, A >::removeBefore(), Vector< T, E, A >::removeFirst(), and Vector< T, E, A >::removeLast().
References Vector< T, E, A >::PreIter::i, and Vector< T, E, A >::removeAt().
References Vector< T, E, A >::removeAt().
References Vector< T, E, A >::removeAt().
References Vector< T, E, A >::clear().
References Vector< T, E, A >::PreIter::i, and Vector< T, E, A >::set().
Referenced by Vector< T, E, A >::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). |
References Vector< T, E, A >::grow().
|
inline |
|
inline |
Get the last item of the vector, that is, the top of the stack represented by the vector.
|
inline |
|
static |