Logo Search packages:      
Sourcecode: ragel version File versions

Vector< T, Resize > Class Template Reference
[Vector]

#include <vector.h>

Inheritance diagram for Vector< T, Resize >:

Table< T >

List of all members.


Detailed Description

template<class T, class Resize = ResizeExpn>
class Vector< T, Resize >

Dynamic array for classes with non-trivial initialization.

This is typical vector implementation. It is a dynamic array that can be used to contain complex data structures that have constructors and destructors as well as simple types such as integers and pointers.

Vector supports inserting, overwriting, and removing single or multiple elements at once. Constructors and destructors are called wherever appropriate. For example, before an element is overwritten, it's destructor is called.

Vector provides automatic resizing of allocated memory as needed and offers different allocation schemes for controlling how the automatic allocation is done. Two senses of the the length of the data is maintained: the amount of raw memory allocated to the vector and the number of actual elements in the vector. The various allocation schemes control how the allocated space is changed in relation to the number of elements in the vector.

Definition at line 36 of file vectcommon.h.


Public Member Functions

void abandon ()
 Forget all elements in the vector.
void empty ()
 Free all memory used by the vector.
IterFirst first ()
 Return first element.
IterLast last ()
 Return last element.
long length () const
 Get the length of the vector.
Vectoroperator= (const Vector &v)
 Deep copy another vector into this vector.
T & operator[] (int i) const
void shallowCopy (const Vector &v)
 Shallow copy another vector into this vector.
long size () const
 Vector (const Vector &v)
 Perform a deep copy of the vector.
 Vector (long size, long allocLen)
 Create a vector with a specified number of initial elements and allocation.
 Vector (long size)
 Create a vector with a specified number of initial elements.
 Vector ()
 Initialize an empty vector with no space allocated.
 ~Vector ()
 Free all memory used by the vector.
void append (const Vector &v)
 Append the contents of another vector.
void append (const T *val, long len)
 Append len elements to the end of the vector.
void append (const T &val)
 Append one elment to the end of the vector.
void appendDup (const T &item, long len)
 Append len copies of item.
void appendNew (long len)
 Append len newly created items.
void appendNew ()
 Append a single newly created item.
void insert (long pos, const Vector &v)
 Insert all the elements from another vector at position pos.
void insert (long pos, const T *val, long len)
 Insert len elements at position pos.
void insert (long pos, const T &val)
 Insert one element at position pos.
void insertDup (long pos, const T &val, long len)
 Insert len copies of item at position pos.
void insertNew (long pos, long len)
 Insert len new elements using the default constructor.
void insertNew (long pos)
 Insert one new element using the default constrcutor.
void prepend (const Vector &v)
 Prepend the contents of another vector.
void prepend (const T *val, long len)
 Prepend len elements to the front of the vector.
void prepend (const T &val)
 Prepend one elment to the front of the vector.
void prependDup (const T &item, long len)
 Prepend len copies of item.
void prependNew (long len)
 Prepend len newly created items.
void prependNew ()
 Prepend a single newly created item.
void remove (long pos, long len)
 Remove len elements at position pos.
void remove (long pos)
 Remove one element at position pos.
void replace (long pos, const Vector &v)
 Replace at position pos with all the elements of another vector.
void replace (long pos, const T *val, long len)
 Replace len elements at position pos.
void replace (long pos, const T &val)
 Replace one element at position pos.
void replaceDup (long pos, const T &val, long len)
 Replace at position pos with len copies of an item.
void replaceNew (long pos, long len)
 Replace at position pos with len new elements.
void replaceNew (long pos)
 Replace at position pos with one new element.
void setAs (const Vector &v)
 Set the vector to exactly the contents of another vector.
void setAs (const T *val, long len)
 Set the contents of the vector to be len elements exactly.
void setAs (const T &val)
 Set the contents of the vector to be val exactly.
void setAsDup (const T &item, long len)
 Set the vector to len copies of item.
void setAsNew (long len)
 Set the vector to exactly len new items.
void setAsNew ()
 Set the vector to exactly one new item.

Public Attributes

long allocLen
 Allocated length.
T * data
 Table data.
long tabLen
 Table length.

Protected Member Functions

void downResize (long len)
void upResize (long len)

Private Types

typedef Table< T > BaseTable

Classes

struct  Iter
 Vector Iterator. More...
struct  IterFirst
struct  IterLast
struct  IterNext
struct  IterPrev

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index