c_array

Table Of Contents

Introduction, c_array

As an alternative to hard coded, or even dynamicly allocated arrays, c_array provides safety, as well as dynamic resizeability. c_array implements all of the functionality of the c_collection base class, while implementing some new functions of it's own. In addition to the saftey and resizeability, c_array provies an access function that allows extremely fast access via an integer index. This is a big advantage over the indexed access methods of the other collection objects.

API Refrence

Example Code for adding elemetns to a collection:
void work_with_an_array( void ) 
{
    c_array<c_string> lines(5);
    
    lines[0] = c_string("line number one");
    lines[1] = c_string("line number two");
    lines[2] = c_string("line number three");
    lines[3] = c_string("line number four");
    lines.add( c_string("line number five");

    // remember that just like fixed arrays, c_array is
    // zero's based.
    cout << "line 3 is: " << lines[2] << endl;

    // this next access would cause an exception to be thrown...
    // cout << "a non-existant line is: " << lines[5] << endl;
}

Up