Scopira
20080306
|
#include <array.h>
Public Types | |
typedef T | data_type |
typedef T * | iterator |
typedef const T * | const_iterator |
Public Member Functions | |
hybrid_array (void) | |
hybrid_array (size_t len) | |
hybrid_array (const hybrid_array &rhs) | |
hybrid_array (const_array_view< T > rhs) | |
~hybrid_array () | |
Destructor. | |
void | resize (size_t newlen) |
T * | array (void) |
const T * | array (void) const |
T * | c_array (void) |
const T * | c_array (void) const |
iterator | begin (void) |
iterator | end (void) |
const_iterator | begin (void) const |
const_iterator | end (void) const |
hybrid_array & | operator= (const hybrid_array &rhs) |
hybrid_array & | operator= (const_array_view< T > rhs) |
void | clear (void) |
void | clear_zero (void) |
size_t | size (void) const |
bool | empty (void) const |
void | set (size_t idx, const T &v) |
const T & | get (size_t idx) const |
T & | get (size_t idx) |
const T & | operator[] (size_t idx) const |
T & | operator[] (size_t idx) |
Protected Attributes | |
fixed_array< T, RES > | dm_fixed |
basic_array< T > | dm_basic |
T * | dm_ary |
size_t | dm_len |
This is a resizable array (like basic_array) thay uses an internal fixed_array (non-heap using) buffer if possible. Very useful for when the array's size rarely exceeds a certain (relativly small) size, and if it does, it'll switch to keep allocation.
Note, that this class does some internally duplication. You should probably only use this for simple, smaller types.
RES is the fixed_array reserve size – after this, the heap will be used.
scopira::tool::hybrid_array< T, RES >::hybrid_array | ( | void | ) |
Default constructor: makes a 0-length array.
|
explicit |
Initialization constructor - makes a array of the given size. Each object will be initializaed via its default constructor (thus primitives will have undefined values).
len | the length of the new array |
References scopira::tool::hybrid_array< T, RES >::resize().
scopira::tool::hybrid_array< T, RES >::hybrid_array | ( | const hybrid_array< T, RES > & | rhs | ) |
scopira::tool::hybrid_array< T, RES >::hybrid_array | ( | const_array_view< T > | rhs | ) |
Deep-copy constructor.
References scopira::tool::const_array_view< T >::begin(), scopira::tool::hybrid_array< T, RES >::begin(), scopira::tool::hybrid_array< T, RES >::empty(), scopira::tool::hybrid_array< T, RES >::end(), scopira::tool::hybrid_array< T, RES >::resize(), and scopira::tool::const_array_view< T >::size().
|
inline |
Raw access to the array
|
inline |
Raw access to the array
|
inline |
STL-like iteration
Referenced by scopira::tool::hybrid_array< T, RES >::hybrid_array(), and scopira::tool::hybrid_array< T, RES >::operator=().
|
inline |
STL-like iteration
|
inline |
Raw access to the array
|
inline |
Raw access to the array
|
inline |
Does a resize(0)
|
inline |
Clears all the array values to binary 0. Does not resize the array. This is dangerous on non-POD classes.
|
inline |
Is the array empty (0 length)?
Referenced by scopira::tool::hybrid_array< T, RES >::hybrid_array().
|
inline |
STL-like iteration
Referenced by scopira::tool::hybrid_array< T, RES >::hybrid_array(), and scopira::tool::hybrid_array< T, RES >::operator=().
|
inline |
STL-like iteration
|
inline |
Individual element setter
|
inline |
Individual element setter
scopira::tool::hybrid_array< T, RES > & scopira::tool::hybrid_array< T, RES >::operator= | ( | const hybrid_array< T, RES > & | rhs | ) |
Copy Operator. Does a deep copy.
References scopira::tool::hybrid_array< T, RES >::begin(), scopira::tool::hybrid_array< T, RES >::end(), and scopira::tool::hybrid_array< T, RES >::resize().
scopira::tool::hybrid_array< T, RES > & scopira::tool::hybrid_array< T, RES >::operator= | ( | const_array_view< T > | rhs | ) |
Copy Operator. Does a deep copy.
References scopira::tool::const_array_view< T >::begin(), scopira::tool::hybrid_array< T, RES >::begin(), scopira::tool::hybrid_array< T, RES >::end(), scopira::tool::hybrid_array< T, RES >::resize(), and scopira::tool::const_array_view< T >::size().
|
inline |
Nice reference access
|
inline |
Nice reference access
void scopira::tool::hybrid_array< T, RES >::resize | ( | size_t | newlen | ) |
Resizes the array. Please note the following: 1) If the new size is the current size, nothing will be done. 2) Resizes are destructive. All old values will be lost, and a new array is constructed (following the initialization rules specified in the constructor description)
newlen | the new length |
References scopira::tool::fixed_array< T, N >::c_array().
Referenced by scopira::tool::hybrid_array< T, RES >::hybrid_array(), and scopira::tool::hybrid_array< T, RES >::operator=().
|
inline |
Individual element setter
|
inline |
Gets the size of the array
Referenced by scopira::tool::hybrid_array< T, RES >::hybrid_array().