|
MoSync 3.3
|
A generic, dynamic, random-access container. More...
#include <MAUtil/Vector.h>
Public Types | |
| typedef Type * | iterator |
| Defines a typesafe iterator for the template instance. | |
| typedef const Type * | const_iterator |
Public Member Functions | |
| Vector (int initialCapacity=4) | |
| Constructs the Vector and sets its capacity to initialCapacity. | |
| Vector (const Type *array, int _size) | |
| Vector (const Vector &other) | |
| ~Vector () | |
| Destructor. | |
| Vector & | operator= (const Vector &other) |
| void | add (const Type &val) |
| Adds an element to the end of the Vector. | |
| void | add (const Type *ptr, int num) |
| Adds several elements to the end of the Vector. | |
| void | remove (iterator i) |
| Removes the element pointed to by iterator i. | |
| void | remove (int index) |
| Removes the element at index. | |
| void | remove (int index, int number) |
| Removes several elements, starting at index. | |
| void | insert (int index, Type t) |
| Inserts the element at index, moving all existing elements beginning at 'index' one step forward. | |
| int | size () const |
| Returns the number of elements. | |
| void | resize (int newSize) |
| Resizes the Vector to contain size elements. | |
| void | reserve (int newCapacity) |
| Reserves space in the Vector. | |
| void | clear () |
| Clears the Vector, setting its size to 0 but not altering its capacity. | |
| bool | empty () const |
| Returns true iff the Vector is empty(). | |
| int | capacity () const |
| Returns the Vector's current capacity. | |
| iterator | begin () |
| Returns an iterator pointing to the first element of the Vector. | |
| iterator | end () |
| Returns an iterator pointing beyond the last element of the Vector. | |
| const_iterator | begin () const |
| Returns an iterator pointing to the first element of the Vector. | |
| const_iterator | end () const |
| Returns an iterator pointing beyond the last element of the Vector. | |
| Type & | operator[] (int index) |
| Returns a reference to the element at index. No range-checking is done. | |
| const Type & | operator[] (int index) const |
| Returns a const reference to the element at index. No range-checking is done. | |
| const Type * | pointer () const |
| Returns a const pointer to the Vector's storage array. | |
| Type * | pointer () |
| Returns a pointer to the Vector's storage array. | |
Protected Attributes | |
| int | mSize |
| int | mCapacity |
| Type * | mData |
A generic, dynamic, random-access container.
Performance characteristics are as follows:
Access to any element by index is very fast (constant time).
add(), insert() and remove() at the end of the vector are fast (constant time amortized over linear time).
insert() and remove() anywhere else are slow, (linear time).
| typedef Type* MAUtil::Vector< Type >::iterator |
Defines a typesafe iterator for the template instance.
| typedef const Type* MAUtil::Vector< Type >::const_iterator |
| MAUtil::Vector< Type >::Vector | ( | int | initialCapacity = 4 | ) | [inline] |
| MAUtil::Vector< Type >::Vector | ( | const Type * | array, |
| int | _size | ||
| ) | [inline] |
| MAUtil::Vector< Type >::Vector | ( | const Vector< Type > & | other | ) | [inline] |
Copies the other vector.
| MAUtil::Vector< Type >::~Vector | ( | ) | [inline] |
Destructor.
| Vector& MAUtil::Vector< Type >::operator= | ( | const Vector< Type > & | other | ) | [inline] |
Copies the other vector.
| void MAUtil::Vector< Type >::add | ( | const Type & | val | ) | [inline] |
Adds an element to the end of the Vector.
| val | The element to be added. |
Referenced by MAUtil::ListenerSet< ConnListener >::add(), NativeUI::addListenerToVector(), MAUtil::Stack< T >::push(), and MAUtil::Vector< IMapCacheListener * >::Vector().
| void MAUtil::Vector< Type >::add | ( | const Type * | ptr, |
| int | num | ||
| ) | [inline] |
Adds several elements to the end of the Vector.
| ptr | A pointer to the elements. |
| num | The number of elements. |
| void MAUtil::Vector< Type >::remove | ( | iterator | i | ) | [inline] |
Removes the element pointed to by iterator i.
| i | An iterator pointing to the element that should be removed. |
Referenced by MAUtil::ListenerSet< ConnListener >::remove(), and NativeUI::removeListenerFromVector().
| void MAUtil::Vector< Type >::remove | ( | int | index | ) | [inline] |
Removes the element at index.
| index | The index of the element that should be removed. |
| void MAUtil::Vector< Type >::remove | ( | int | index, |
| int | number | ||
| ) | [inline] |
Removes several elements, starting at index.
| index | The index of the element that should be removed. |
| number | The number of elements to remove. |
| void MAUtil::Vector< Type >::insert | ( | int | index, |
| Type | t | ||
| ) | [inline] |
Inserts the element at index, moving all existing elements beginning at 'index' one step forward.
| index | The index of the newly inserted element. |
| t | The element itself. |
| int MAUtil::Vector< Type >::size | ( | ) | const [inline] |
Returns the number of elements.
Referenced by NativeUI::addListenerToVector(), MAUtil::Stack< T >::empty(), MAP::GeoPointDataSource::onDataChanged(), MAP::GeoPointDataSource::onLoadComplete(), MAUtil::Stack< T >::peek(), MAUtil::Stack< T >::pop(), NativeUI::removeListenerFromVector(), MAUtil::ListenerSet< ConnListener >::setRunning(), MAUtil::Stack< T >::size(), and MAUtil::ListenerSet< ConnListener >::size().
| void MAUtil::Vector< Type >::resize | ( | int | newSize | ) | [inline] |
Resizes the Vector to contain size elements.
| newSize | The desired size of the Vector. |
Referenced by MAUtil::Vector< IMapCacheListener * >::clear(), MAUtil::Vector< IMapCacheListener * >::insert(), MAUtil::Stack< T >::pop(), MAUtil::Vector< IMapCacheListener * >::remove(), and MAUtil::ListenerSet< ConnListener >::setRunning().
| void MAUtil::Vector< Type >::reserve | ( | int | newCapacity | ) | [inline] |
Reserves space in the Vector.
| newCapacity | The desired capacity of the Vector. |
Referenced by MAUtil::Vector< IMapCacheListener * >::add(), and MAUtil::Vector< IMapCacheListener * >::resize().
| void MAUtil::Vector< Type >::clear | ( | ) | [inline] |
Clears the Vector, setting its size to 0 but not altering its capacity.
Referenced by MAUtil::Stack< T >::clear().
| bool MAUtil::Vector< Type >::empty | ( | ) | const [inline] |
| int MAUtil::Vector< Type >::capacity | ( | ) | const [inline] |
| iterator MAUtil::Vector< Type >::begin | ( | ) | [inline] |
Returns an iterator pointing to the first element of the Vector.
Referenced by MAUtil::Vector< IMapCacheListener * >::insert(), and MAUtil::Vector< IMapCacheListener * >::remove().
| iterator MAUtil::Vector< Type >::end | ( | ) | [inline] |
Returns an iterator pointing beyond the last element of the Vector.
Referenced by MAUtil::Vector< IMapCacheListener * >::insert(), and MAUtil::Vector< IMapCacheListener * >::remove().
| const_iterator MAUtil::Vector< Type >::begin | ( | ) | const [inline] |
Returns an iterator pointing to the first element of the Vector.
| const_iterator MAUtil::Vector< Type >::end | ( | ) | const [inline] |
Returns an iterator pointing beyond the last element of the Vector.
| Type& MAUtil::Vector< Type >::operator[] | ( | int | index | ) | [inline] |
Returns a reference to the element at index. No range-checking is done.
| index | The index of the element to be returned. |
| const Type& MAUtil::Vector< Type >::operator[] | ( | int | index | ) | const [inline] |
Returns a const reference to the element at index. No range-checking is done.
| index | The index of the element to be returned. |
| const Type* MAUtil::Vector< Type >::pointer | ( | ) | const [inline] |
| Type* MAUtil::Vector< Type >::pointer | ( | ) | [inline] |
int MAUtil::Vector< Type >::mSize [protected] |
Referenced by MAUtil::Vector< IMapCacheListener * >::add(), MAUtil::Vector< IMapCacheListener * >::empty(), MAUtil::Vector< IMapCacheListener * >::end(), MAUtil::Vector< IMapCacheListener * >::insert(), MAUtil::Vector< IMapCacheListener * >::operator=(), MAUtil::Vector< IMapCacheListener * >::remove(), MAUtil::Vector< IMapCacheListener * >::reserve(), MAUtil::Vector< IMapCacheListener * >::resize(), MAUtil::Vector< IMapCacheListener * >::size(), and MAUtil::Vector< IMapCacheListener * >::Vector().
int MAUtil::Vector< Type >::mCapacity [protected] |
Type* MAUtil::Vector< Type >::mData [protected] |
Referenced by MAUtil::Vector< IMapCacheListener * >::add(), MAUtil::Vector< IMapCacheListener * >::begin(), MAUtil::Vector< IMapCacheListener * >::end(), MAUtil::Vector< IMapCacheListener * >::operator=(), MAUtil::Vector< IMapCacheListener * >::operator[](), MAUtil::Vector< IMapCacheListener * >::pointer(), MAUtil::Vector< IMapCacheListener * >::remove(), MAUtil::Vector< IMapCacheListener * >::reserve(), MAUtil::Vector< IMapCacheListener * >::resize(), MAUtil::Vector< IMapCacheListener * >::Vector(), and MAUtil::Vector< IMapCacheListener * >::~Vector().