|
OpenTTD
|
fixed size array Upon construction it preallocates fixed size block of memory for all items, but doesn't construct them. More...
#include <fixedsizearray.hpp>
Data Structures | |
| struct | ArrayHeader |
| header for fixed size array More... | |
Public Member Functions | |
| FixedSizeArray () | |
| Default constructor. | |
| FixedSizeArray (const FixedSizeArray< T, C > &src) | |
| Copy constructor. | |
| ~FixedSizeArray () | |
| destroy remaining items and free the memory block | |
| void | Clear () |
| Clear (destroy) all items. | |
| uint | Length () const |
| return number of used items | |
| bool | IsFull () const |
| return true if array is full | |
| bool | IsEmpty () const |
| return true if array is empty | |
| T * | Append () |
| add (allocate), but don't construct item | |
| T * | AppendC () |
| add and construct item using default constructor | |
| T & | operator[] (uint index) |
| return item by index (non-const version) | |
| const T & | operator[] (uint index) const |
| return item by index (const version) | |
Protected Member Functions | |
| ArrayHeader & | Hdr () |
| return reference to the array header (non-const) | |
| const ArrayHeader & | Hdr () const |
| return reference to the array header (const) | |
| uint & | RefCnt () |
| return reference to the block reference counter | |
| uint & | SizeRef () |
| return reference to number of used items | |
Protected Attributes | |
| T * | data |
| the only member of fixed size array is pointer to the block of C array of items. | |
Static Protected Attributes | |
| static const uint | Tsize = sizeof(T) |
| size of item | |
| static const uint | HeaderSize = sizeof(ArrayHeader) |
| size of header | |
fixed size array Upon construction it preallocates fixed size block of memory for all items, but doesn't construct them.
Item's construction is delayed.
Definition at line 24 of file fixedsizearray.hpp.
|
inline |
Default constructor.
Preallocate space for items and header, then initialize header.
Definition at line 54 of file fixedsizearray.hpp.
|
inline |
Copy constructor.
Preallocate space for items and header, then initialize header.
Definition at line 66 of file fixedsizearray.hpp.
|
protected |
the only member of fixed size array is pointer to the block of C array of items.
Header can be found on the offset -sizeof(ArrayHeader).
Definition at line 41 of file fixedsizearray.hpp.
Referenced by FixedSizeArray< SubArray, 1024 >::Append(), FixedSizeArray< SubArray, 1024 >::Clear(), FixedSizeArray< SubArray, 1024 >::FixedSizeArray(), FixedSizeArray< SubArray, 1024 >::Hdr(), FixedSizeArray< SubArray, 1024 >::operator[](), and FixedSizeArray< SubArray, 1024 >::~FixedSizeArray().
1.8.1.2