#include <array.h>
Collaboration diagram for Array:
Public Methods | |
Array () | |
unsigned int | size () |
void | grow () |
void | ensure_capacity () |
void | append (T element) |
T | operator[] (unsigned int index) |
void | clear () |
Protected Attributes | |
T * | data |
unsigned int | used_size |
unsigned int | capacity |
Static Protected Attributes | |
const unsigned int | INITIAL_CAPACITY = 8 |
|
Initialize a null array of zero elements and zero capacity. grow() should be called before first using the array.
|
|
Add an element to the end of the array.
|
|
Clear the array and free its memory.
|
|
Ensure that there's enough capacity for the current used_size.
|
|
Expand the array's total capacity. This would be faster if there was a realloc() implementation.
|
|
Return a particular indexed element. No bounds checking is performed.
|
|
Return the number of currently used elements.
|
|
number of possible elements that can be used before growth is required.
|
|
actual array elements.
|
|
|
|
number of elements currently in use.
|
Torsion Operating System, Copyright (C) 2000-2002 Dan Helfman