jcpp::StringVector Class Reference

#include <StringVector.h>

Inheritance diagram for jcpp::StringVector:

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

Collaboration graph
[legend]

List of all members.

Public Member Functions

CDELETE StringVector (int initialCapacity)
CDELETE StringVector (int initialCapacity, int increment)
void add (char *str)
void addElement (char *str)
int capacity ()
CDELETE Objectclone ()
boolean contains (char *elem)
char * elementAt (int index)
CDELETE StringEnumerationelements ()
void ensureCapacity (int newCapacity)
char * firstElement ()
char * get (int idx)
int indexOf (char *elem)
int indexOf (char *elem, int index)
void insertElementAt (char *str, int index)
boolean isEmpty ()
char * lastElement ()
int lastIndexOf (char *elem)
int lastIndexOf (char *elem, int index)
CFREE char * remove (int idx)
void removeAllElements ()
boolean removeElement (char *str)
void removeElementAt (int index)
void setElementAt (char *str, int index)
void setSize (int newSize)
int size ()
char * toString ()
void trimToSize ()
void doAll (StringIterated &)
CFREE char ** toArgv (int &argc)
void copyOut (char **array, int length)
void sort ()

Protected Attributes

int capacityIncrement
int elementCount
CFREE char ** 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::StringVector::StringVector ( int  initialCapacity,
int  increment 
)

0 increment indicates doubling on reallocation


Member Function Documentation

int jcpp::StringVector::indexOf ( char *  elem,
int  index 
)

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

CFREE char* jcpp::StringVector::remove ( int  idx  ) 

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

void jcpp::StringVector::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::StringVector::removeElement ( char *  str  ) 

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::StringVector::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::StringVector::setElementAt ( char *  str,
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::StringVector::doAll ( StringIterated  ) 

apply the StringIterated do() given to all elements of the the vector. The user is expected to know what they are doing.

CFREE char** jcpp::StringVector::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. free the return value, not the data in its pointers. This is not a classical argv ala C in that it is not NULL-terminated.

void jcpp::StringVector::copyOut ( char **  array,
int  length 
)

Copy char *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::StringVector::sort (  ) 

sort strings by strcmp + qsort.


Member Data Documentation

expansion size

number of actual entries

total capacity


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

Generated on Thu Mar 17 13:10:47 2011 for CCAFFEINE by  doxygen 1.5.9