Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

WvVectorBase Class Reference

#include <wvvector.h>

Inherited by WvVector< T >.

Collaboration diagram for WvVectorBase:

[legend]
List of all members.

Detailed Description

The untyped vector base type.

See also:
WvVector

Definition at line 17 of file wvvector.h.

Public Member Functions

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

 WvVectorBase (bool _auto_free)
 Creates an empty vector.

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


Constructor & Destructor Documentation

WvVectorBase::WvVectorBase bool  _auto_free  )  [protected]
 

Creates an empty vector.

Definition at line 11 of file wvvector.cc.

References xcount, and xseq.


Member Function Documentation

void WvVectorBase::append void *  elem  )  [protected]
 

Appends an element onto the tail of the vector.

Definition at line 56 of file wvvector.cc.

References growcapacity(), setcapacity(), xcount, and xseq.

Referenced by WvVector< T >::append().

int WvVectorBase::capacity  )  const [inline]
 

The number of elements that could be stored without resizing.

Definition at line 60 of file wvvector.h.

void WvVectorBase::compact  )  [inline]
 

Compacts the vector to minimize its footprint.

Definition at line 72 of file wvvector.h.

References count(), and setcapacity().

int WvVectorBase::count  )  const [inline]
 

Returns the number of elements actually stored in the vector.

Definition at line 52 of file wvvector.h.

References xcount.

Referenced by compact().

int WvVectorBase::growcapacity int  minslots  )  [protected]
 

Computes the number of slots needed to grow to at least minslots.

Definition at line 19 of file wvvector.cc.

References MINALLOC.

Referenced by append(), and insert().

void WvVectorBase::insert int  slot,
void *  elem
[protected]
 

Inserts an element at the specified slot.

Definition at line 47 of file wvvector.cc.

References growcapacity(), moveelems(), setcapacity(), xcount, and xseq.

Referenced by WvVector< T >::insert().

bool WvVectorBase::isempty  )  const [inline]
 

Returns true if the vector is empty.

Definition at line 56 of file wvvector.h.

References xcount.

void WvVectorBase::moveelems void *  dst,
void *  src,
int  nelems
[inline, protected]
 

A shorthand for memmove() with size adjustment.

Definition at line 38 of file wvvector.h.

Referenced by insert(), remove(), and setcapacity().

void WvVectorBase::remove int  slot  )  [protected]
 

Removes the element at the specified slot.

Definition at line 39 of file wvvector.cc.

References moveelems(), setcapacity(), shrinkcapacity(), xcount, and xseq.

Referenced by WvVector< T >::remove().

void WvVectorBase::setcapacity int  newslots  ) 
 

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 moveelems(), xcount, and xseq.

Referenced by append(), compact(), insert(), and remove().

int WvVectorBase::shrinkcapacity int  maxslots  )  [protected]
 

Computes the number of slots needed to shrink down to maxslots.

Definition at line 29 of file wvvector.cc.

Referenced by remove().


Member Data Documentation

bool WvVectorBase::auto_free [protected]
 

whether to auto-delete the elements when removed

Definition at line 26 of file wvvector.h.

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

the minimum number of slots to allocate

Definition at line 20 of file wvvector.h.

Referenced by growcapacity().

int WvVectorBase::xcount [protected]
 

the number of elements in the sequence

Definition at line 24 of file wvvector.h.

Referenced by append(), count(), insert(), isempty(), remove(), setcapacity(), and WvVectorBase().

void** WvVectorBase::xseq [protected]
 

the controlled sequence

Definition at line 23 of file wvvector.h.

Referenced by append(), insert(), remove(), setcapacity(), and WvVectorBase().

int WvVectorBase::xslots [protected]
 

the capacity of the array

Definition at line 25 of file wvvector.h.


The documentation for this class was generated from the following files:
Generated on Sat Mar 13 15:00:42 2004 for WvStreams by doxygen 1.3.6-20040222