CommonLibSSE (powerof3)
GArrayData.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/G/GArrayDataBase.h"
4 
5 namespace RE
6 {
7  template <class T, class Allocator, class SizePolicy>
8  struct GArrayData : GArrayDataBase<T, Allocator, SizePolicy>
9  {
10  public:
11  using ValueType = T;
12  using AllocatorType = Allocator;
13  using SizePolicyType = SizePolicy;
16 
18  BaseType()
19  {}
20 
21  GArrayData(std::int32_t a_size) :
22  BaseType()
23  {
24  Resize(a_size);
25  }
26 
27  GArrayData(const SelfType& a_arrayData) :
28  BaseType(a_arrayData.policy)
29  {
30  Append(a_arrayData.data, a_arrayData.size);
31  }
32 
33  void Reserve(UPInt a_newCapacity)
34  {
35  BaseType::Reserve(this, a_newCapacity);
36  }
37 
38  void Resize(UPInt a_newSize)
39  {
40  UPInt oldSize = this->size;
41  BaseType::ResizeNoConstruct(this, a_newSize);
42  if (a_newSize > oldSize) {
43  Allocator::ConstructArray(this->data + oldSize, a_newSize - oldSize);
44  }
45  }
46 
47  void PushBack(const ValueType& a_val)
48  {
49  BaseType::ResizeNoConstruct(this, this->size + 1);
50  Allocator::Construct(this->data + this->size - 1, a_val);
51  }
52 
53  template <class S>
54  void PushBackAlt(const S& a_val)
55  {
56  BaseType::ResizeNoConstruct(this, this->size + 1);
57  Allocator::ConstructAlt(this->data + this->size - 1, a_val);
58  }
59 
60  void Append(const ValueType a_other[], UPInt a_count)
61  {
62  if (a_count) {
63  UPInt oldSize = this->size;
64  BaseType::ResizeNoConstruct(this, this->size + a_count);
65  Allocator::ConstructArray(this->data + oldSize, a_count, a_other);
66  }
67  }
68  };
69 }
Definition: AbsorbEffect.h:6
std::size_t UPInt
Definition: SFTypes.h:5
Definition: GArrayDataBase.h:7
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
UPInt size
Definition: GArrayDataBase.h:99
SizePolicy policy
Definition: GArrayDataBase.h:100
Definition: GArrayData.h:9
void PushBackAlt(const S &a_val)
Definition: GArrayData.h:54
void Resize(UPInt a_newSize)
Definition: GArrayData.h:38
void PushBack(const ValueType &a_val)
Definition: GArrayData.h:47
void Reserve(UPInt a_newCapacity)
Definition: GArrayData.h:33
T ValueType
Definition: GArrayData.h:11
Allocator AllocatorType
Definition: GArrayData.h:12
GArrayData(std::int32_t a_size)
Definition: GArrayData.h:21
void Append(const ValueType a_other[], UPInt a_count)
Definition: GArrayData.h:60
SizePolicy SizePolicyType
Definition: GArrayData.h:13
GArrayData()
Definition: GArrayData.h:17
GArrayData(const SelfType &a_arrayData)
Definition: GArrayData.h:27