Rudiments: dynamicarray< valuetype > Class Template Reference

Rudiments

Public Member Functions | List of all members
dynamicarray< valuetype > Class Template Reference

## Public Member Functions
| dynamicarray ()
| dynamicarray (uint64_t initiallength, uint64_t incrementlength)
| dynamicarray (const dynamicarray< valuetype > &v)
dynamicarray< valuetype > & | operator= (const dynamicarray< valuetype > &v)
| ~dynamicarray ()
valuetype & | operator[] (uint64_t index)
uint64_t | getInitialLength () const
uint64_t | getIncrementLength () const
uint64_t | getLength () const
void | clear ()
void | clear (uint64_t initiallength, uint64_t incrementlength)

## Detailed Description

### template<class valuetype>
class dynamicarray< valuetype >

The dynamicarray class allows you to store an arbitrary number of values and access them with array-like syntax.

Internally, the class stores these values in a series of extents. The size of the initial and incremental extents are defined in the constructor.

"valuetype" can be any scalar type, including a pointer, but cannot be an array.

Ie. these are legal: dynamicarray< int > d; dynamicarray< myclass > d; dynamicarray< myclass * > d;

These are not legal and whether they work or even compile would be platform-dependent: dynamicarray< int[100] > d; dynamicarray< myclass[100] > d; dynamicarray< myclass *[100] > d;

However, it is possible to create an array of arrays by nesting dynamicarrays and/or staticarrays, like:

    dynamicarray< dynamicarray< int > > d;
    dynamicarray< dynamicarray< myclass > > d;
    dynamicarray< dynamicarray< myclass * > > d;
    dynamicarray< staticarray< int > > d;
    dynamicarray< staticarray< myclass > > d;
    dynamicarray< staticarray< myclass * > > d;

## Constructor & Destructor Documentation

## ◆ dynamicarray() [1/3]

template<class valuetype >

dynamicarray< valuetype >::dynamicarray
| inline

Creates an empty instance of the dynamicarray class.

## ◆ dynamicarray() [2/3]

template<class valuetype >

dynamicarray< valuetype >::dynamicarray | ( | uint64_t | initiallength,
|  | uint64_t | incrementlength
| ) |  |
| inline

Creates an empty instance of the dynamicarray class. The initial extent will be created with "initiallength" members and each successive extent will be created with "incrementlength" members.

## ◆ dynamicarray() [3/3]

template<class valuetype >

dynamicarray< valuetype >::dynamicarray | ( | const dynamicarray< valuetype > & | v | ) |
| inline

Creates an instance of the dynamicarray class that is a copy of "v".

## ◆ ~dynamicarray()

template<class valuetype >

dynamicarray< valuetype >::~dynamicarray
| inline

Deletes this instance of the dynamicarray class and all of its values.

## Member Function Documentation

## ◆ clear() [1/2]

template<class valuetype >

void dynamicarray< valuetype >::clear
| inline

Clears the array, deleting all of its values.

## ◆ clear() [2/2]

template<class valuetype >

void dynamicarray< valuetype >::clear | ( | uint64_t | initiallength,
|  | uint64_t | incrementlength
| ) |  |
| inline

Clears the array, deleting all of its values and resetting the lengths of the initial and incremental extents.

## ◆ getLength()

template<class valuetype >

uint64_t dynamicarray< valuetype >::getLength
| inline

Returns the number of elements in the array.

## ◆ operator=()

template<class valuetype >

dynamicarray< valuetype > & dynamicarray< valuetype >::operator= | ( | const dynamicarray< valuetype > & | v | ) |
| inline

Makes this instance of the dynamicarray class identical to "v".

## ◆ operator[]()

template<class valuetype >

valuetype & dynamicarray< valuetype >::operator[] | ( | uint64_t | index | ) |
| inline

Provides access to the "index"th element of the dynamicarray.