#include <Vector.h>
Public Member Functions | |
CDELETE | Vector (int initialCapacity) |
CDELETE | Vector (int initialCapacity, int increment) |
void | add (Object *obj) |
void | addElement (Object *obj) |
int | capacity () |
CDELETE Object * | clone () |
boolean | contains (Object *elem) |
Object * | elementAt (int index) |
CDELETE Enumeration * | elements () |
void | ensureCapacity (int newCapacity) |
Object * | firstElement () |
Object * | get (int idx) |
int | indexOf (Object *elem) |
int | indexOf (Object *elem, int index) |
void | insertElementAt (Object *obj, int index) |
boolean | isEmpty () |
Object * | lastElement () |
int | lastIndexOf (Object *elem) |
int | lastIndexOf (Object *elem, int index) |
CDELETE Object * | remove (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 |
CDELETE jcpp::Vector::Vector | ( | int | initialCapacity, | |
int | increment | |||
) |
0 increment indicates doubling on reallocation
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.