Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Class Members | File Members | Related Pages

WvVector< T > Class Template Reference

#include <wvvector.h>

Inheritance diagram for WvVector< T >:

[legend]
List of all members.

Detailed Description

template<class T>
class WvVector< T >

A dynamic array data structure with constant time lookup, linear time insertion / removal, and expected logarithmic time append.


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

static const int MINALLOC = 4

Classes

class  Iter
 A simple iterator that walks through all elements in the list. More...


Member Function Documentation

void WvVectorBase::setcapacity 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.


Member Data Documentation

const int WvVectorBase::MINALLOC = 4 [static, protected, inherited]
 

the minimum number of slots to allocate

void** WvVectorBase::xseq [protected, inherited]
 

the controlled sequence

int WvVectorBase::xcount [protected, inherited]
 

the number of elements in the sequence

int WvVectorBase::xslots [protected, inherited]
 

the capacity of the array

bool WvVectorBase::auto_free [protected, inherited]
 

whether to auto-delete the elements when removed


The documentation for this class was generated from the following file:
Generated on Sun Apr 3 14:48:26 2005 for WvStreams by  doxygen 1.4.2