1
0
mirror of https://github.com/OpenTTD/OpenTTD.git synced 2025-08-26 07:59:09 +00:00

(svn r18826) -Codechange: Unifiy return value of (SmallArray|FixedSizeArray)::(Append|AppendC) with other containers. (skidd13)

This commit is contained in:
frosch
2010-01-16 14:22:19 +00:00
parent 84ece021fd
commit 6465f02fba
4 changed files with 8 additions and 8 deletions

View File

@@ -35,7 +35,7 @@ protected:
SubArray& s = data[super_size - 1];
if (!s.IsFull()) return s;
}
return data.AppendC();
return *data.AppendC();
}
public:
@@ -56,9 +56,9 @@ public:
/** return true if array is full */
FORCEINLINE bool IsFull() { return data.IsFull() && data[N - 1].IsFull(); }
/** allocate but not construct new item */
FORCEINLINE T& Append() { return FirstFreeSubArray().Append(); }
FORCEINLINE T *Append() { return FirstFreeSubArray().Append(); }
/** allocate and construct new item */
FORCEINLINE T& AppendC() { return FirstFreeSubArray().AppendC(); }
FORCEINLINE T *AppendC() { return FirstFreeSubArray().AppendC(); }
/** indexed access (non-const) */
FORCEINLINE T& operator [] (uint index)
{

View File

@@ -93,9 +93,9 @@ public:
/** return true if array is empty */
FORCEINLINE bool IsEmpty() const { return Length() <= 0; };
/** add (allocate), but don't construct item */
FORCEINLINE T& Append() { assert(!IsFull()); return data[SizeRef()++]; }
FORCEINLINE T *Append() { assert(!IsFull()); return &data[SizeRef()++]; }
/** add and construct item using default constructor */
FORCEINLINE T& AppendC() { T& item = Append(); new(&item)T; return item; }
FORCEINLINE T *AppendC() { T *item = Append(); new(item)T; return item; }
/** return item by index (non-const version) */
FORCEINLINE T& operator [] (uint index) { assert(index < Length()); return data[index]; }
/** return item by index (const version) */