#include <array.h>
Inheritance diagram for Array< T >:


Public Member Functions | |
| Array (bool physical=false, Size init_capacity=0) | |
| void | init (bool physical=false, Size init_capacity=0) |
| Size | size () |
| void | set_size (unsigned new_size) |
| Size | get_capacity () |
| void | grow (bool set_size_too=false) |
| void | ensure_capacity () |
| T & | append (T &element) |
| T & | operator[] (unsigned index) |
| void | clear () |
Protected Attributes | |
| T * | data |
| Size | used_size |
| Size | capacity |
| Size | init_capacity |
| bool | physical |
Static Protected Attributes | |
| const Size | INITIAL_VIRTUAL_CAPACITY = 8 |
| const Size | INITIAL_PHYSICAL_CAPACITY = PAGE_SIZE / sizeof(T) |
It can be based on either virtual or physical memory. Growing the array's capacity is performed automatically on demand.
|
||||||||||||||||
|
Call init() with the given arguments.
|
|
||||||||||
|
Add an element to the end of the array and return a reference to it within the array.
|
|
|||||||||
|
Clear the array and free its memory.
|
|
|||||||||
|
Ensure that there's enough capacity for the current used_size.
|
|
|||||||||
|
Return the current array capacity.
|
|
||||||||||
|
Expand the array's total capacity. If set_size_too is true, then the array's used_size will be set to the same value as the new capacity. |
|
||||||||||||||||
|
Initialize a null array of zero elements and zero capacity. Set physical to true if the array data should be allocated from physical memory. Otherwise, leave physical false and data will be allocated from persistent virtual memory. An initial array capacity can be provided to override the default capacity. |
|
||||||||||
|
Return a particular indexed element. No bounds checking is performed.
|
|
||||||||||
|
Set the used size of the array manually. This is useful if you want to just start addressing individual elements of the array. |
|
|||||||||
|
Return the number of currently used elements. This is distinct from the current capacity of the array. |
|
|||||
|
number of possible elements that can be used before growth is required
|
|
|||||
|
actual array elements
|
|
|||||
|
capacity to set on initialization
|
|
|||||
|
|
|
|||||
|
|
|
|||||
|
whether to use physical allocator
|
|
|||||
|
number of elements currently in use
|
Torsion Operating System, Copyright (C) 2000-2004 Dan Helfman