#include <wvvector.h>
Inherits WvVectorBase.
Collaboration diagram for WvVector< T >:
Definition at line 83 of file wvvector.h.
Public Member Functions | |
WvVector (bool _auto_free) | |
Creates an empty vector. | |
~WvVector () | |
Destroys the vector and all of its contents. | |
T * | operator[] (int slot) |
Dereferences a particular slot of the vector. | |
void | zap () |
Removes all elements from the vector. | |
void | remove (int slot, bool never_delete=false) |
void | remove_last () |
Removes the last element. | |
T * | last () |
void | insert (int slot, T *elem) |
void | append (T *elem) |
T ** | ptr () |
int | count () const |
Returns the number of elements actually stored in the vector. | |
bool | isempty () const |
Returns true if the vector is empty. | |
int | capacity () const |
The number of elements that could be stored without resizing. | |
void | setcapacity (int newslots) |
Adjusts the capacity of the vector. | |
void | compact () |
Compacts the vector to minimize its footprint. | |
Protected Member Functions | |
int | growcapacity (int minslots) |
Computes the number of slots needed to grow to at least minslots. | |
int | shrinkcapacity (int maxslots) |
Computes the number of slots needed to shrink down to maxslots. | |
void | moveelems (void *dst, void *src, int nelems) |
A shorthand for memmove() with size adjustment. | |
void | remove (int slot) |
Removes the element at the specified slot. | |
void | insert (int slot, void *elem) |
Inserts an element at the specified slot. | |
void | append (void *elem) |
Appends an element onto the tail of the vector. | |
Protected Attributes | |
void ** | xseq |
int | xcount |
int | xslots |
bool | auto_free |
Static Protected Attributes | |
const int | MINALLOC = 4 |
|
Creates an empty vector.
Definition at line 87 of file wvvector.h. |
|
Destroys the vector and all of its contents.
Definition at line 91 of file wvvector.h. References WvVector< T >::zap(). |
|
Appends an element onto the tail of the vector.
Definition at line 56 of file wvvector.cc. References WvVectorBase::append(), WvVectorBase::growcapacity(), WvVectorBase::setcapacity(), WvVectorBase::xcount, and WvVectorBase::xseq. Referenced by WvVectorBase::append(). |
|
Definition at line 133 of file wvvector.h. References WvVector< T >::append(). Referenced by WvVector< T >::append(). |
|
The number of elements that could be stored without resizing.
Definition at line 60 of file wvvector.h. References WvVectorBase::xslots. |
|
Compacts the vector to minimize its footprint.
Definition at line 72 of file wvvector.h. References WvVectorBase::count(). |
|
Returns the number of elements actually stored in the vector.
Definition at line 52 of file wvvector.h. References WvVectorBase::xcount. Referenced by WvVectorBase::compact(). |
|
Computes the number of slots needed to grow to at least minslots.
Definition at line 19 of file wvvector.cc. References WvVectorBase::growcapacity(), WvVectorBase::MINALLOC, and WvVectorBase::xslots. Referenced by WvVectorBase::append(), WvVectorBase::growcapacity(), and WvVectorBase::insert(). |
|
Inserts an element at the specified slot.
Definition at line 47 of file wvvector.cc. References WvVectorBase::growcapacity(), WvVectorBase::insert(), WvVectorBase::moveelems(), WvVectorBase::setcapacity(), WvVectorBase::xcount, and WvVectorBase::xseq. Referenced by WvVectorBase::insert(). |
|
Definition at line 130 of file wvvector.h. References WvVector< T >::insert(). Referenced by WvVector< T >::insert(). |
|
Returns true if the vector is empty.
Definition at line 56 of file wvvector.h. References WvVectorBase::xcount. |
|
Definition at line 127 of file wvvector.h. |
|
A shorthand for memmove() with size adjustment.
Definition at line 38 of file wvvector.h. References WvVectorBase::moveelems(). Referenced by WvVectorBase::insert(), WvVectorBase::moveelems(), WvVectorBase::remove(), and WvVectorBase::setcapacity(). |
|
Dereferences a particular slot of the vector.
Definition at line 95 of file wvvector.h. References WvVector< T >::ptr(). |
|
Definition at line 137 of file wvvector.h. Referenced by WvVector< T >::operator[](), and WvVector< T >::zap(). |
|
Removes the element at the specified slot.
Definition at line 39 of file wvvector.cc. References WvVectorBase::moveelems(), WvVectorBase::remove(), WvVectorBase::setcapacity(), WvVectorBase::shrinkcapacity(), WvVectorBase::xcount, and WvVectorBase::xseq. Referenced by WvVectorBase::remove(). |
|
Definition at line 115 of file wvvector.h. References WvVector< T >::remove(). Referenced by WvVector< T >::remove(). |
|
Removes the last element.
Definition at line 124 of file wvvector.h. |
|
Adjusts the capacity of the vector. If the new capacity is greater than the old one, extends the array size without actually filling in any elements. Definition at line 64 of file wvvector.cc. References WvVectorBase::moveelems(), WvVectorBase::setcapacity(), WvVectorBase::xcount, WvVectorBase::xseq, and WvVectorBase::xslots. Referenced by WvVectorBase::append(), WvVectorBase::insert(), WvVectorBase::remove(), and WvVectorBase::setcapacity(). |
|
Computes the number of slots needed to shrink down to maxslots.
Definition at line 29 of file wvvector.cc. References WvVectorBase::shrinkcapacity(), and WvVectorBase::xslots. Referenced by WvVectorBase::remove(), and WvVectorBase::shrinkcapacity(). |
|
Removes all elements from the vector.
Definition at line 99 of file wvvector.h. References WvVector< T >::ptr(). Referenced by WvVector< T >::~WvVector(). |
|
whether to auto-delete the elements when removed Definition at line 26 of file wvvector.h. Referenced by WvVectorBase::WvVectorBase(). |
|
the minimum number of slots to allocate Definition at line 20 of file wvvector.h. Referenced by WvVectorBase::growcapacity(). |
|
the number of elements in the sequence Definition at line 24 of file wvvector.h. Referenced by WvVectorBase::append(), WvVectorBase::count(), WvVectorBase::insert(), WvVectorBase::isempty(), WvVectorBase::remove(), WvVectorBase::setcapacity(), and WvVectorBase::WvVectorBase(). |
|
the controlled sequence Definition at line 23 of file wvvector.h. Referenced by WvVectorBase::append(), WvVectorBase::insert(), WvVectorBase::remove(), WvVectorBase::setcapacity(), and WvVectorBase::WvVectorBase(). |
|
the capacity of the array Definition at line 25 of file wvvector.h. Referenced by WvVectorBase::capacity(), WvVectorBase::growcapacity(), WvVectorBase::setcapacity(), WvVectorBase::shrinkcapacity(), and WvVectorBase::WvVectorBase(). |