OpenTTD Source
1.11.0-beta2
|
Go to the documentation of this file.
20 template <
class T, u
int B = 1024, u
int N = B>
57 if (super_size == 0)
return 0;
59 return (super_size - 1) * B + sub_size;
89 T &item = s[index % B];
96 const T &item = s[index % B];
104 template <
typename D>
void Dump(D &dmp)
const
106 dmp.WriteLine(
"capacity = %d",
Tcapacity);
107 uint num_items =
Length();
108 dmp.WriteLine(
"num_items = %d", num_items);
110 for (uint i = 0; i < num_items; i++) {
111 const T &item = (*this)[i];
112 name.Format(
"item[%d]", i);
113 dmp.WriteStructT(name.
Data(), &item);
void Clear()
Clear (destroy) all items.
void Dump(D &dmp) const
Helper for creating a human readable output of this data.
Blob based case sensitive ANSI/UTF-8 string.
T * Append()
allocate but not construct new item
uint Length() const
Return actual number of items.
bool IsFull()
return true if array is full
SubArray & FirstFreeSubArray()
return first sub-array with free space for new item
void Clear()
Clear (destroy) all items.
bool IsEmpty() const
return true if array is empty
T * AppendC()
allocate and construct new item
FixedSizeArray< T, B > SubArray
inner array
Flexible array with size limit.
static const uint Tcapacity
total max number of items
SuperArray data
array of arrays of items
T * Append()
add (allocate), but don't construct item
bool IsFull() const
return true if array is full
fixed size array Upon construction it preallocates fixed size block of memory for all items,...
bool IsEmpty()
return true if array is empty
FixedSizeArray< SubArray, N > SuperArray
outer array
uint Length() const
return number of used items
SmallArray()
implicit constructor
T & operator[](uint index)
indexed access (non-const)
T * Data()
Return pointer to the first data item - non-const version.
T * AppendC()
add and construct item using default constructor