#include <wvvector.h>
Definition at line 253 of file wvvector.h.
Public Types | |
typedef int(* | comparison_type_fn_t )(const T *, const T *) |
Runs the C qsort() routine over the vector, as long as the vector is big enough. | |
Public Member Functions | |
WvVector () | |
Creates an empty vector. | |
WvVector (int slots) | |
Creates an empty vector, but initialises a new number of default slots. | |
~WvVector () | |
Destroys the vector and all of its contents. | |
T * | operator[] (int slot) |
Dereferences a particular slot of the vector. | |
const T * | operator[] (int slot) const |
T * | first () |
Returns the first element. | |
T * | last () |
Returns the last element. | |
void | remove (int slot, bool destroy=true) |
Removes a particular slot from the vector. | |
void | remove_last (bool destroy=true) |
Removes the last element. | |
void | zap (bool destroy=true) |
Removes all elements from the vector. | |
void | insert (int slot, T *elem, bool autofree) |
Insert an element into a slot, and shifts the others to the right. | |
void | prepend (T *elem, bool autofree) |
Prepends an element to the start of the vector. | |
void | append (T *elem, bool autofree) |
Appends an element to the end of the vector. | |
void | qsort (comparison_type_fn_t comparator) |
int | count () const |
Returns the number of elements actually stored in the vector. | |
bool | isempty () const |
Returns true if the vector is empty. | |
int | get_capacity () const |
The number of elements that could be stored without resizing. | |
void | set_capacity (int newslots) |
Adjusts the capacity of the vector. | |
void | compact () |
Compacts the vector to minimize its footprint. | |
Protected Types | |
typedef int(* | comparison_type_t )(const void *, const void *) |
Protected Member Functions | |
void | remove (int slot) |
Removes the element at the specified slot. | |
void | insert (int slot, WvLink *elem) |
Inserts an element at the specified slot. | |
void | prepend (WvLink *elem) |
Prepend an element onto the front of the vector. | |
void | append (WvLink *elem) |
Appends an element onto the tail of the vector. | |
bool | get_autofree (int slot) |
Gets autofree for the specified slot. | |
void | set_autofree (int slot, bool autofree) |
Sets autofree for the specified slot. | |
Static Protected Member Functions | |
static int | wrapcomparator (const void *_a, const void *_b) |
Protected Attributes | |
WvLink ** | xseq |
int | xcount |
int | xslots |
Static Protected Attributes | |
static const int | DEFAULTSIZE = 4 |
Friends | |
class | IterBase |
Classes | |
class | Iter |
A simple iterator that walks through all elements in the list. More... |
typedef int(* WvVector< T >::comparison_type_fn_t)(const T *, const T *) |
Runs the C qsort() routine over the vector, as long as the vector is big enough.
It uses comparator like qsort() does to figure out the order of the operators.
T* WvVector< T >::operator[] | ( | int | slot | ) | [inline] |
void WvVector< T >::remove | ( | int | slot, | |
bool | destroy = true | |||
) | [inline] |
void WvVector< T >::zap | ( | bool | destroy = true |
) | [inline] |
Removes all elements from the vector.
Definition at line 334 of file wvvector.h.
Referenced by WvVector< UniConf >::~WvVector().
void WvVector< T >::insert | ( | int | slot, | |
T * | elem, | |||
bool | autofree | |||
) | [inline] |
Insert an element into a slot, and shifts the others to the right.
Definition at line 341 of file wvvector.h.
void WvVectorBase::remove | ( | int | slot | ) | [protected, inherited] |
Removes the element at the specified slot.
Definition at line 18 of file wvvector.cc.
References WvVectorBase::xcount, and WvVectorBase::xseq.
Referenced by WvVector< UniConf >::remove().
void WvVectorBase::insert | ( | int | slot, | |
WvLink * | elem | |||
) | [protected, inherited] |
Inserts an element at the specified slot.
Definition at line 26 of file wvvector.cc.
References WvVectorBase::set_capacity(), WvVectorBase::xcount, WvVectorBase::xseq, and WvVectorBase::xslots.
Referenced by WvVector< UniConf >::insert(), and WvVectorBase::prepend().
void WvVectorBase::prepend | ( | WvLink * | elem | ) | [inline, protected, inherited] |
Prepend an element onto the front of the vector.
Definition at line 50 of file wvvector.h.
References WvVectorBase::insert().
Referenced by WvVector< UniConf >::prepend().
void WvVectorBase::append | ( | WvLink * | elem | ) | [protected, inherited] |
Appends an element onto the tail of the vector.
Definition at line 41 of file wvvector.cc.
References WvVectorBase::set_capacity(), WvVectorBase::xcount, WvVectorBase::xseq, and WvVectorBase::xslots.
Referenced by WvVector< UniConf >::append().
bool WvVectorBase::get_autofree | ( | int | slot | ) | [inline, protected, inherited] |
Gets autofree for the specified slot.
Definition at line 59 of file wvvector.h.
References WvLink::get_autofree(), WvVectorBase::xcount, and WvVectorBase::xseq.
void WvVectorBase::set_autofree | ( | int | slot, | |
bool | autofree | |||
) | [inline, protected, inherited] |
Sets autofree for the specified slot.
Definition at line 67 of file wvvector.h.
References WvLink::set_autofree(), WvVectorBase::xcount, and WvVectorBase::xseq.
int WvVectorBase::count | ( | ) | const [inline, inherited] |
Returns the number of elements actually stored in the vector.
Definition at line 98 of file wvvector.h.
References WvVectorBase::xcount.
bool WvVectorBase::isempty | ( | ) | const [inline, inherited] |
Returns true if the vector is empty.
Definition at line 104 of file wvvector.h.
References WvVectorBase::xcount.
int WvVectorBase::get_capacity | ( | ) | const [inline, inherited] |
The number of elements that could be stored without resizing.
Definition at line 110 of file wvvector.h.
References WvVectorBase::xslots.
void WvVectorBase::set_capacity | ( | int | newslots | ) | [inherited] |
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 53 of file wvvector.cc.
References WvVectorBase::xcount, WvVectorBase::xseq, and WvVectorBase::xslots.
Referenced by WvVectorBase::append(), WvVectorBase::compact(), WvVectorBase::insert(), and WvVectorBase::WvVectorBase().
void WvVectorBase::compact | ( | ) | [inline, inherited] |
Compacts the vector to minimize its footprint.
Definition at line 124 of file wvvector.h.
References WvVectorBase::set_capacity(), and WvVectorBase::xcount.
const int WvVectorBase::DEFAULTSIZE = 4 [static, protected, inherited] |
the minimum number of slots to allocate
Definition at line 26 of file wvvector.h.
WvLink** WvVectorBase::xseq [protected, inherited] |
the controlled sequence
Definition at line 29 of file wvvector.h.
Referenced by WvVectorBase::append(), WvVectorBase::get_autofree(), WvVectorBase::insert(), WvVector< UniConf >::operator[](), WvVector< UniConf >::remove(), WvVectorBase::remove(), WvVectorBase::set_autofree(), WvVectorBase::set_capacity(), and WvVectorBase::~WvVectorBase().
int WvVectorBase::xcount [protected, inherited] |
the number of elements in the sequence
Definition at line 30 of file wvvector.h.
Referenced by WvVectorBase::append(), WvVectorBase::compact(), WvVectorBase::count(), WvVector< UniConf >::first(), WvVectorBase::get_autofree(), WvVectorBase::insert(), WvVectorBase::isempty(), WvVector< UniConf >::last(), WvVector< UniConf >::operator[](), WvVector< UniConf >::remove(), WvVectorBase::remove(), WvVector< UniConf >::remove_last(), WvVectorBase::set_autofree(), WvVectorBase::set_capacity(), and WvVector< UniConf >::zap().
int WvVectorBase::xslots [protected, inherited] |
the capacity of the array
Definition at line 31 of file wvvector.h.
Referenced by WvVectorBase::append(), WvVectorBase::get_capacity(), WvVectorBase::insert(), and WvVectorBase::set_capacity().