#include <utils.h>
Inheritance diagram for CB2::Array< Tmemb >:
Public Types | |
typedef Array< Tmemb > | this_type |
Template type alias. | |
typedef size_t | size_type |
Size type. | |
typedef Tmemb * | ref_type |
Item reference type. | |
typedef Iterator< this_type, ref_type, Tmemb > | iterator |
Iterator. | |
typedef RevIterator< this_type, ref_type, Tmemb > | rev_iterator |
Reverse iterator. | |
Public Member Functions | |
Array (const size_type fragment=4096) | |
Default constructor. | |
Array (const this_type &prev) | |
Copy constructor. | |
~Array () | |
Desctructor. | |
const this_type & | operator= (const this_type &prev) |
Copy assignment. | |
operator const Tmemb * () const | |
Implicit conversion operator. | |
const this_type & | operator<< (const Tmemb &prev) |
Append item at the end. | |
const this_type & | operator>> (const Tmemb &prev) |
Append item at the beginning. | |
const this_type & | operator+= (const size_type nmemb) |
Enlarge array by a number of items. | |
const this_type & | operator-= (const size_type nmemb) |
Shrink array by a number of items. | |
Tmemb & | operator[] (const size_type pos) const |
Get item reference. | |
void | Fill (const Tmemb *buffer, const size_type nmemb) |
Copy items from C-style array. | |
void | Discart (const bool shrink=false) |
Discart the array. | |
size_type | Len () const |
Return number of items. | |
bool | Empty () const |
Check array for empty. | |
ref_type | RefBegin () const |
Get starting reference. | |
ref_type | RefEnd () const |
Get final reference. | |
ref_type | RevRefBegin () const |
Get starting reverse reference. | |
ref_type | RevRefEnd () const |
Get final reverse reference. | |
ref_type | RefNext (const ref_type &prev) const |
Get succeding reference. | |
ref_type | RefPrev (const ref_type &prev) const |
Get predecessing reference. | |
const Tmemb & | Deref (const ref_type &ref) const |
Dereference. | |
const Tmemb & | RevDeref (const ref_type &ref) const |
TODO. | |
iterator | Begin () const |
Get starting iterator. | |
iterator | End () const |
Get final iterator. | |
rev_iterator | RevBegin () const |
Get starting reverse iterator. | |
rev_iterator | RevEnd () const |
Get final reverse iterator. | |
void | Cut (const size_type pos, const size_type cnt) |
Cut out piece of array. | |
void | Insert (const size_type pos, const size_type cnt, const this_type &ins) |
Insert items. | |
Public Attributes | |
int | tag |
Tag for user-specific data. | |
Private Member Functions | |
void | allocate (const size_type nlen) |
Allocate memory for items. | |
void | privatize (const this_type &prev) |
Copy data from another array. | |
Private Attributes | |
Tmemb * | data |
Data storage. | |
size_type | allocated |
Allocated memory space. | |
size_type | len |
Members used. | |
size_type | frag |
Fragment size. |
Multipurpose array type for storing values of the same kind. Grows in fragments, never shrinks by inself (shrinks only explicitly on Discart(true) method).
Note: This is a low-level array class, the elements are stored and copied bit-by-bit (no copy constructors or class assignments are called). Use List for storing class objects.
NB: As a low-level storage implementation, many operations have strict limitations on self-reference (i.e. you shouldn't insert values referenced from the same array instance). Use List for more robust (but slower) implementation.
|
|
|
Item reference type.
|
|
Reverse iterator.
|
|
Size type.
|
|
Template type alias.
|
|
Default constructor. Create empty array.
|
|
Copy constructor. Copy array items from another array (copy is bit-by-bit).
|
|
Desctructor. Dispose the memory of the array. |
|
Allocate memory for items. Allocate or reallocate memory for items. The memory is rounded to nearest fragment. If the new count of items is lower then the original count, the memory pool is untouched. If the allocation/reallocation fails, ExceptionMemory is thrown.
|
|
Get starting iterator.
|
|
Cut out piece of array. Remove several items from the array. The items are defined by the position of the first removed item and count of items that follows (and should be removed). If 'pos' or 'cnt' is out of range, ExceptionRange is thrown.
|
|
Dereference. Get the item value referenced by 'ref'. If the reference is out of range, ExceptionMemory is thrown.
|
|
Discart the array. Discart the contents of the array.
|
|
Check array for empty.
|
|
Get final iterator.
|
|
Copy items from C-style array. Copy items from a standard C-style array. Members are copied bit-by-bit. Original contents of the array is discarted.
|
|
Insert items. Insert items from another array into this array. The first item from 'ins' is inserted at index 'pos' and totally 'cnt' items are inserted (previous items on these positions are shifted back). If 'pos' or 'cnt' is out of range, ExceptionRange is thrown. NB: This method doesn't support self-reference. If 'ins' is this same array, ExceptionAssert is thrown.
|
|
Return number of items.
|
|
Implicit conversion operator. Returns constant pointer to the array.
|
|
Enlarge array by a number of items. Enlarge the array by allocating memory for 'nmemb' items at the end. The contents of the items is undefined.
|
|
Shrink array by a number of items. Shrink the array by disposing 'nmemb' items at the end. If a larger count of items than the length of the array is specified, the array made empty.
|
|
Append item at the end. Append one item at the end of the array.
|
|
Copy assignment. Copy array items from another array (copy is bit-by-bit).
|
|
Append item at the beginning. Append item at the beginning of the array. Note: The appended item should not be a reference to another item from this array (in this case a wrong item will be appended).
|
|
Get item reference. Get reference to an item from the array indexed by 'pos'. If 'pos' is out of range, ExceptionRange is thrown.
|
|
Copy data from another array. Copy data from another array, unless this is self-reference.
|
|
Get starting reference. Get the reference to the first item in the array as a pointer to the first item (or NULL on empty array).
|
|
Get final reference. Get the final reference as the pointer to the memory position after the last item in the array (or NULL on empty array).
|
|
Get succeding reference. Get the reference to an item succeding the item referenced by 'prev' (i.e. increase the pointer by one item). If the pointer is final or invalid, final reference is returned).
|
|
Get predecessing reference. Get the reference to an item predecessing the item referenced by 'prev' (i.e. decrease the pointer by one item). If the pointer is final or invalid, final reference is returned).
|
|
Get starting reverse iterator.
|
|
TODO.
|
|
Get final reverse iterator.
|
|
Get starting reverse reference. Get the reference to the last item in the array as a pointer RefEnd().
|
|
Get final reverse reference. Get the final reverse reference, which is equivaltent to the starting forward reference.
|
|
Allocated memory space.
|
|
Data storage.
|
|
Fragment size.
|
|
Members used.
|
|
Tag for user-specific data.
|