mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-09 15:41:15 +00:00
(svn r18826) -Codechange: Unifiy return value of (SmallArray|FixedSizeArray)::(Append|AppendC) with other containers. (skidd13)
This commit is contained in:
parent
84ece021fd
commit
6465f02fba
@ -35,7 +35,7 @@ protected:
|
|||||||
SubArray& s = data[super_size - 1];
|
SubArray& s = data[super_size - 1];
|
||||||
if (!s.IsFull()) return s;
|
if (!s.IsFull()) return s;
|
||||||
}
|
}
|
||||||
return data.AppendC();
|
return *data.AppendC();
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -56,9 +56,9 @@ public:
|
|||||||
/** 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(); }
|
||||||
/** 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 */
|
||||||
FORCEINLINE T& AppendC() { return FirstFreeSubArray().AppendC(); }
|
FORCEINLINE T *AppendC() { return FirstFreeSubArray().AppendC(); }
|
||||||
/** indexed access (non-const) */
|
/** indexed access (non-const) */
|
||||||
FORCEINLINE T& operator [] (uint index)
|
FORCEINLINE T& operator [] (uint index)
|
||||||
{
|
{
|
||||||
|
@ -93,9 +93,9 @@ public:
|
|||||||
/** return true if array is empty */
|
/** return true if array is empty */
|
||||||
FORCEINLINE bool IsEmpty() const { return Length() <= 0; };
|
FORCEINLINE bool IsEmpty() const { return Length() <= 0; };
|
||||||
/** add (allocate), but don't construct item */
|
/** 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 */
|
/** 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) */
|
/** return item by index (non-const version) */
|
||||||
FORCEINLINE T& operator [] (uint index) { assert(index < Length()); return data[index]; }
|
FORCEINLINE T& operator [] (uint index) { assert(index < Length()); return data[index]; }
|
||||||
/** return item by index (const version) */
|
/** return item by index (const version) */
|
||||||
|
@ -74,7 +74,7 @@ public:
|
|||||||
/** allocate new data item from m_arr */
|
/** allocate new data item from m_arr */
|
||||||
FORCEINLINE Titem_ *CreateNewNode()
|
FORCEINLINE Titem_ *CreateNewNode()
|
||||||
{
|
{
|
||||||
if (m_new_node == NULL) m_new_node = &m_arr.AppendC();
|
if (m_new_node == NULL) m_new_node = m_arr.AppendC();
|
||||||
return m_new_node;
|
return m_new_node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ public:
|
|||||||
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
FORCEINLINE bool PfNodeCacheFetch(Node& n)
|
||||||
{
|
{
|
||||||
CacheKey key(n.GetKey());
|
CacheKey key(n.GetKey());
|
||||||
Yapf().ConnectNodeToCachedData(n, *new (&m_local_cache.Append()) CachedData(key));
|
Yapf().ConnectNodeToCachedData(n, *new (m_local_cache.Append()) CachedData(key));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +133,7 @@ struct CSegmentCostCacheT
|
|||||||
Tsegment *item = m_map.Find(key);
|
Tsegment *item = m_map.Find(key);
|
||||||
if (item == NULL) {
|
if (item == NULL) {
|
||||||
*found = false;
|
*found = false;
|
||||||
item = new (&m_heap.Append()) Tsegment(key);
|
item = new (m_heap.Append()) Tsegment(key);
|
||||||
m_map.Push(*item);
|
m_map.Push(*item);
|
||||||
} else {
|
} else {
|
||||||
*found = true;
|
*found = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user