5 template <
class T,
class Allocator,
class SizePolicy>
28 Allocator::DestructArray(
data,
size);
29 Allocator::Free(
data);
34 return policy.GetCapacity();
39 Allocator::DestructArray(
data,
size);
40 Allocator::Free(
data);
51 if (a_newCapacity <
policy.GetMinCapacity())
52 a_newCapacity =
policy.GetMinCapacity();
54 if (a_newCapacity == 0) {
56 Allocator::Free(
data);
62 UPInt newCapacity = (a_newCapacity + gran - 1) / gran * gran;
64 if (Allocator::IsMovable()) {
65 data = (T*)Allocator::Realloc(
data,
sizeof(T) * newCapacity);
67 T* newData = (T*)Allocator::Alloc(a_heapAddr,
sizeof(T) * newCapacity);
69 Allocator::Construct(&newData[i],
data[i]);
70 Allocator::Destruct(&
data[i]);
72 Allocator::Free(
data);
76 data = (T*)Allocator::Alloc(a_heapAddr,
sizeof(T) * newCapacity);
78 policy.SetCapacity(newCapacity);
86 if (a_newSize < oldSize) {
87 Allocator::DestructArray(
data + a_newSize, oldSize - a_newSize);
88 if (a_newSize < (
policy.GetCapacity() >> 1)) {
91 }
else if (a_newSize >=
policy.GetCapacity()) {
92 Reserve(a_heapAddr, a_newSize + (a_newSize >> 2));
#define KEEP_FOR_RE()
Definition: PCH.h:713
Definition: AbsorbEffect.h:6
std::size_t UPInt
Definition: SFTypes.h:5
Definition: GArrayDataBase.h:7
T ValueType
Definition: GArrayDataBase.h:9
UPInt GetCapacity() const
Definition: GArrayDataBase.h:32
SizePolicy SizePolicyType
Definition: GArrayDataBase.h:11
GArrayDataBase()
Definition: GArrayDataBase.h:14
void ClearAndRelease()
Definition: GArrayDataBase.h:37
void ResizeNoConstruct(const void *a_heapAddr, UPInt a_newSize)
Definition: GArrayDataBase.h:82
void Reserve(const void *a_heapAddr, UPInt a_newCapacity)
Definition: GArrayDataBase.h:46
T * data
Definition: GArrayDataBase.h:98
GArrayDataBase(const SizePolicy &a_policy)
Definition: GArrayDataBase.h:20
Allocator AllocatorType
Definition: GArrayDataBase.h:10
~GArrayDataBase()
Definition: GArrayDataBase.h:26
UPInt size
Definition: GArrayDataBase.h:99
SizePolicy policy
Definition: GArrayDataBase.h:100