|
|
@ -19,16 +19,26 @@
|
|
|
|
* array of fixed size arrays */
|
|
|
|
* array of fixed size arrays */
|
|
|
|
template <class T, uint B = 1024, uint N = B>
|
|
|
|
template <class T, uint B = 1024, uint N = B>
|
|
|
|
class SmallArray {
|
|
|
|
class SmallArray {
|
|
|
|
public:
|
|
|
|
protected:
|
|
|
|
typedef FixedSizeArray<T, B> SubArray; ///< inner array
|
|
|
|
typedef FixedSizeArray<T, B> SubArray; ///< inner array
|
|
|
|
typedef FixedSizeArray<SubArray, N> SuperArray; ///< outer array
|
|
|
|
typedef FixedSizeArray<SubArray, N> SuperArray; ///< outer array
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static const uint Tcapacity = B * N; ///< total max number of items
|
|
|
|
|
|
|
|
|
|
|
|
SuperArray data; ///< array of arrays of items
|
|
|
|
SuperArray data; ///< array of arrays of items
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** return first sub-array with free space for new item */
|
|
|
|
static const uint Tcapacity = B * N; ///< total max number of items
|
|
|
|
FORCEINLINE SubArray& FirstFreeSubArray()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint super_size = data.Length();
|
|
|
|
|
|
|
|
if (super_size > 0) {
|
|
|
|
|
|
|
|
SubArray& s = data[super_size - 1];
|
|
|
|
|
|
|
|
if (!s.IsFull()) return s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return data.AppendC();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
/** implicit constructor */
|
|
|
|
/** implicit constructor */
|
|
|
|
FORCEINLINE SmallArray() { }
|
|
|
|
FORCEINLINE SmallArray() { }
|
|
|
|
/** Clear (destroy) all items */
|
|
|
|
/** Clear (destroy) all items */
|
|
|
@ -45,16 +55,6 @@ public:
|
|
|
|
FORCEINLINE bool IsEmpty() { return data.IsEmpty(); }
|
|
|
|
FORCEINLINE bool IsEmpty() { return data.IsEmpty(); }
|
|
|
|
/** return true if array is full */
|
|
|
|
/** return true if array is full */
|
|
|
|
FORCEINLINE bool IsFull() { return data.IsFull() && data[N - 1].IsFull(); }
|
|
|
|
FORCEINLINE bool IsFull() { return data.IsFull() && data[N - 1].IsFull(); }
|
|
|
|
/** return first sub-array with free space for new item */
|
|
|
|
|
|
|
|
FORCEINLINE SubArray& FirstFreeSubArray()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint super_size = data.Length();
|
|
|
|
|
|
|
|
if (super_size > 0) {
|
|
|
|
|
|
|
|
SubArray& s = data[super_size - 1];
|
|
|
|
|
|
|
|
if (!s.IsFull()) return s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return data.AppendC();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/** allocate but not construct new item */
|
|
|
|
/** allocate but not construct new item */
|
|
|
|
FORCEINLINE T& Append() { return FirstFreeSubArray().Append(); }
|
|
|
|
FORCEINLINE T& Append() { return FirstFreeSubArray().Append(); }
|
|
|
|
/** allocate and construct new item */
|
|
|
|
/** allocate and construct new item */
|
|
|
|