jcpp::Vector Class Reference

#include <Vector.h>

Inheritance diagram for jcpp::Vector:

Inheritance graph
[legend]
Collaboration diagram for jcpp::Vector:

Collaboration graph
[legend]

List of all members.

Public Member Functions

CDELETE Vector (int initialCapacity)
CDELETE Vector (int initialCapacity, int increment)
void add (Object *obj)
void addElement (Object *obj)
int capacity ()
CDELETE Objectclone ()
boolean contains (Object *elem)
ObjectelementAt (int index)
CDELETE Enumerationelements ()
void ensureCapacity (int newCapacity)
ObjectfirstElement ()
Objectget (int idx)
int indexOf (Object *elem)
int indexOf (Object *elem, int index)
void insertElementAt (Object *obj, int index)
boolean isEmpty ()
ObjectlastElement ()
int lastIndexOf (Object *elem)
int lastIndexOf (Object *elem, int index)
CDELETE Objectremove (int idx)
void removeAllElements ()
boolean removeElement (Object *obj)
void removeElementAt (int index)
void setElementAt (Object *obj, int index)
void setSize (int newSize)
int size ()
char * toString ()
void trimToSize ()
void doAll (ObjectIterated &f)
CFREE Object ** toArgv (int &argc)
void copyOut (Object **array, int length)
void addString (char *str)
char * getString (int idx)

Protected Attributes

int capacityIncrement
int elementCount
CFREE Object ** elementData
int elementData_length

Private Member Functions

void increaseCapacity ()

Static Private Attributes

static const int DEFAULTCAP


Detailed Description

A vector class with interface similar to the Java vector, but this class is concrete, not an interface spec and not really expected to be subclassed.

Constructor & Destructor Documentation

CDELETE jcpp::Vector::Vector ( int  initialCapacity,
int  increment 
)

0 increment indicates doubling on reallocation


Member Function Documentation

int jcpp::Vector::indexOf ( Object elem,
int  index 
)

Elem must be in vector, not just have same value of some element, except in the case of strings.

CDELETE Object* jcpp::Vector::remove ( int  idx  ) 

Delete element at index specified and return that element. memory of returned element becomes callers responsibility.

void jcpp::Vector::removeAllElements (  ) 

The use of this function may not be too bright, as it does not call any destructors on the elements as they are removed.

boolean jcpp::Vector::removeElement ( Object obj  ) 

The use of this function may not be too bright, as it does not call any destructors on the elements as they are removed.

void jcpp::Vector::removeElementAt ( int  index  ) 

The use of this function may not be too bright, as it does not call any destructors on the elements as they are removed.

void jcpp::Vector::setElementAt ( Object obj,
int  index 
)

The use of this function may not be too bright, as it does not call any destructors on the elements as they are overwritten.

void jcpp::Vector::setSize ( int  newSize  ) 

Set the number of active entries in the vector, initing them to 0 if the size is an expansion.

int jcpp::Vector::size (  ) 

Get the number of active entries in the vector.

void jcpp::Vector::trimToSize (  ) 

Truncate the vector.

void jcpp::Vector::doAll ( ObjectIterated f  ) 

Apply the function f given to all elements of the the vector. The user is expected to know what they are doing.

CFREE Object* * jcpp::Vector::toArgv ( int &  argc  ) 

Return an array of pointers to vector elements and set argc to the length of the array. If malloc fails, argc -> -1, return NULL.

void jcpp::Vector::copyOut ( Object **  array,
int  length 
)

Copy Object *s from vector into users array, which must be at least as long as the size of the vector. length is the space available in the array given. If array is bigger than vector, its remaining entries will be set to NULL.

void jcpp::Vector::addString ( char *  str  ) 

Mosquito functions. These will sting you if you don't know exactly what you are doing with your pointers. In particular Enumeration will not return the string pointers, but instead their Object wrappers.

char* jcpp::Vector::getString ( int  idx  ) 

Return the string value at element idx, if that element is indeed a string.

Returns:
NULL if idxth element is not a string.


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

Generated on Tue Apr 28 03:13:03 2009 for CCAFFEINE by  doxygen 1.5.5