CommonLibSSE (powerof3)
BSTArray.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/M/MemoryManager.h"
4 
5 namespace RE
6 {
7  class ScrapHeap;
8 
10  {
11  public:
12  using size_type = std::uint32_t;
13 
15  {
16  public:
17  inline static constexpr auto RTTI = RTTI_BSTArrayBase__IAllocatorFunctor;
18  inline static constexpr auto VTABLE = VTABLE_BSTArrayBase__IAllocatorFunctor;
19 
20  // add
21  virtual bool Allocate(std::uint32_t a_num, std::uint32_t a_elemSize) = 0; // 00
22  virtual bool Reallocate(std::uint32_t a_minNewSizeInItems, std::uint32_t a_frontCopyCount, std::uint32_t a_shiftCount, std::uint32_t a_backCopyCount, std::uint32_t a_elemSize) = 0; // 01
23  virtual void Deallocate() = 0; // 02
24 
25  virtual ~IAllocatorFunctor() = default; // 03
26 
28  };
29  static_assert(sizeof(IAllocatorFunctor) == 0x8);
30 
31  constexpr BSTArrayBase() noexcept = default;
32  constexpr BSTArrayBase(const BSTArrayBase&) noexcept = default;
33  constexpr BSTArrayBase(BSTArrayBase&&) noexcept = default;
34 
35  inline ~BSTArrayBase() noexcept { _size = 0; }
36 
37  BSTArrayBase& operator=(const BSTArrayBase&) noexcept = default;
38  BSTArrayBase& operator=(BSTArrayBase&&) noexcept = default;
39 
40  [[nodiscard]] constexpr bool empty() const noexcept { return _size == 0; }
41  [[nodiscard]] constexpr size_type size() const noexcept { return _size; }
42 
43  protected:
44  constexpr void set_size(size_type a_size) noexcept { _size = a_size; }
45 
46  private:
47  // members
48  std::uint32_t _size{ 0 }; // 0
49  };
50  static_assert(sizeof(BSTArrayBase) == 0x4);
51 
53  {
54  public:
55  using size_type = std::uint32_t;
56 
57  constexpr BSTArrayHeapAllocator() noexcept = default;
58 
60  {
61  if (a_rhs.data()) {
62  _capacity = a_rhs.capacity();
63  _data = allocate(capacity());
64  std::memcpy(data(), a_rhs.data(), capacity());
65  }
66  }
67 
68  constexpr BSTArrayHeapAllocator(BSTArrayHeapAllocator&& a_rhs) noexcept :
69  _data(a_rhs.data()),
70  _capacity(a_rhs.capacity())
71  {
72  a_rhs._data = nullptr;
73  a_rhs._capacity = 0;
74  }
75 
77  {
78  deallocate(data());
79  _data = nullptr;
80  _capacity = 0;
81  }
82 
84  {
85  if (this != std::addressof(a_rhs)) {
86  deallocate(data());
87  _data = nullptr;
88  _capacity = 0;
89 
90  if (a_rhs.data()) {
91  _capacity = a_rhs.capacity();
92  _data = allocate(capacity());
93  std::memcpy(data(), a_rhs.data(), capacity());
94  }
95  }
96  return *this;
97  }
98 
100  {
101  if (this != std::addressof(a_rhs)) {
102  deallocate(data());
103  _data = a_rhs.data();
104  _capacity = a_rhs.capacity();
105 
106  a_rhs._data = nullptr;
107  a_rhs._capacity = 0;
108  }
109  return *this;
110  }
111 
113 
114  [[nodiscard]] constexpr void* data() noexcept { return _data; }
115  [[nodiscard]] constexpr const void* data() const noexcept { return _data; }
116 
117  [[nodiscard]] constexpr size_type capacity() const noexcept { return _capacity; }
118 
119  protected:
120  inline void* allocate(std::size_t a_size)
121  {
122  const auto mem = malloc(a_size);
123  if (!mem) {
124  stl::report_and_fail("out of memory"sv);
125  } else {
126  std::memset(mem, 0, a_size);
127  return mem;
128  }
129  }
130 
131  inline void deallocate(void* a_ptr) { free(a_ptr); }
132 
133  constexpr void set_allocator_traits(void* a_data, std::uint32_t a_capacity, std::size_t) noexcept
134  {
135  _data = a_data;
136  _capacity = a_capacity;
137  }
138 
139  private:
140  // members
141  void* _data{ nullptr }; // 00
142  std::uint32_t _capacity{ 0 }; // 08
143  };
144  static_assert(sizeof(BSTArrayHeapAllocator) == 0x10);
145 
146  template <std::uint32_t N>
148  {
149  public:
150  using size_type = std::uint32_t;
151 
152  constexpr BSTSmallArrayHeapAllocator() noexcept :
153  _capacity(0),
154  _local(1)
155  {}
156 
158  _capacity(0),
159  _local(1)
160  {
161  copy(a_rhs);
162  }
163 
165  _capacity(0),
166  _local(1)
167  {
168  copy(std::move(a_rhs));
169  }
170 
171  inline ~BSTSmallArrayHeapAllocator() { release(); }
172 
174  {
175  if (this != std::addressof(a_rhs)) {
176  copy(a_rhs);
177  }
178  return *this;
179  }
180 
182  {
183  if (this != std::addressof(a_rhs)) {
184  copy(std::move(a_rhs));
185  }
186  return *this;
187  }
188 
190 
191  [[nodiscard]] constexpr void* data() noexcept { return local() ? _data.local : _data.heap; }
192  [[nodiscard]] constexpr const void* data() const noexcept { return local() ? _data.local : _data.heap; }
193 
194  [[nodiscard]] constexpr size_type capacity() const noexcept { return _capacity; }
195 
196  protected:
197  void* allocate(std::size_t a_size)
198  {
199  if (a_size > N) {
200  const auto mem = malloc(a_size);
201  if (!mem) {
202  stl::report_and_fail("out of memory"sv);
203  } else {
204  std::memset(mem, 0, a_size);
205  return mem;
206  }
207  } else {
208  return _data.local;
209  }
210  }
211 
212  void deallocate(void* a_ptr)
213  {
214  if (a_ptr != _data.local) {
215  free(a_ptr);
216  }
217  }
218 
219  constexpr void set_allocator_traits(void* a_data, std::uint32_t a_capacity, std::size_t a_typeSize) noexcept
220  {
221  _capacity = a_capacity;
222  if (a_capacity * a_typeSize > N) {
223  _local = 0;
224  _data.heap = a_data;
225  }
226  }
227 
228  private:
229  union Data
230  {
231  void* heap;
232  char local[N]{ 0 };
233  };
234 
235  inline void copy(const BSTSmallArrayHeapAllocator& a_rhs)
236  {
237  release();
238 
239  _capacity = a_rhs._capacity;
240  _local = a_rhs._local;
241 
242  if (!local()) {
243  const auto mem = malloc(capacity());
244  if (!mem) {
245  stl::report_and_fail("out of memory"sv);
246  } else {
247  _data.heap = mem;
248  }
249  }
250 
251  std::memcpy(data(), a_rhs.data(), capacity());
252  }
253 
254  inline void copy(BSTSmallArrayHeapAllocator&& a_rhs)
255  {
256  release();
257 
258  _capacity = a_rhs._capacity;
259  _local = a_rhs._local;
260  std::memmove(data(), a_rhs.data(), capacity());
261 
262  std::memset(a_rhs.data(), 0, a_rhs.capacity());
263  a_rhs._capacity = N;
264  a_rhs._local = 1;
265  }
266 
267  [[nodiscard]] constexpr bool local() const noexcept { return _local != 0; }
268 
269  inline void release()
270  {
271  if (!local()) {
272  free(_data.heap);
273  }
274 
275  std::memset(data(), 0, capacity());
276  _capacity = N;
277  _local = 1;
278  }
279 
280  // members
281  std::uint32_t _capacity: 31; // 00
282  std::uint32_t _local: 1; // 00
283  Data _data; // 08
284  };
285 
287  {
288  public:
289  using size_type = std::uint32_t;
290 
291  constexpr BSScrapArrayAllocator() noexcept = default;
292 
294  _capacity(a_rhs._capacity)
295  {
296  if (capacity() > 0) {
297  _data = allocate(capacity());
298  std::memcpy(data(), a_rhs.data(), capacity());
299  }
300  }
301 
302  constexpr BSScrapArrayAllocator(BSScrapArrayAllocator&& a_rhs) noexcept :
303  _allocator(a_rhs._allocator),
304  _data(a_rhs._data),
305  _capacity(a_rhs._capacity)
306  {
307  a_rhs._allocator = nullptr;
308  a_rhs._data = nullptr;
309  a_rhs._capacity = 0;
310  }
311 
313 
315  {
316  if (this != std::addressof(a_rhs)) {
317  if (_data) {
318  deallocate(_data);
319  _data = nullptr;
320  }
321 
322  _capacity = a_rhs.capacity();
323  if (capacity() > 0) {
324  _data = allocate(capacity());
325  std::memcpy(data(), a_rhs.data(), capacity());
326  }
327  }
328  return *this;
329  }
330 
332  {
333  if (this != std::addressof(a_rhs)) {
334  if (_data) {
335  deallocate(_data);
336  }
337 
338  _allocator = a_rhs._allocator;
339  _data = a_rhs._data;
340  _capacity = a_rhs._capacity;
341 
342  a_rhs._allocator = nullptr;
343  a_rhs._data = nullptr;
344  a_rhs._capacity = 0;
345  }
346  return *this;
347  }
348 
350 
351  [[nodiscard]] constexpr void* data() noexcept { return _data; }
352  [[nodiscard]] constexpr const void* data() const noexcept { return _data; }
353 
354  [[nodiscard]] constexpr size_type capacity() const noexcept { return _capacity; }
355 
356  protected:
357  void* allocate(std::size_t a_size);
358  void deallocate(void* a_ptr);
359 
360  constexpr void set_allocator_traits(void* a_data, std::uint32_t a_capacity, std::size_t) noexcept
361  {
362  _data = a_data;
363  _capacity = a_capacity;
364  }
365 
366  private:
367  // members
368  ScrapHeap* _allocator{ nullptr }; // 00
369  void* _data{ nullptr }; // 08
370  size_type _capacity{ 0 }; // 10
371  };
372  static_assert(sizeof(BSScrapArrayAllocator) == 0x18);
373 
374  template <class T, class Allocator = BSTArrayHeapAllocator>
375  class BSTArray :
376  public Allocator,
377  public BSTArrayBase
378  {
379  public:
380  using allocator_type = Allocator;
382  using value_type = T;
383  using pointer = value_type*;
384  using const_pointer = const value_type*;
386  using const_reference = const value_type&;
387  using iterator = pointer;
389 
390  BSTArray() = default;
391 
392  inline BSTArray(const BSTArray& a_rhs)
393  {
394  const auto newCapacity = a_rhs.capacity();
395  if (newCapacity == 0) {
396  return;
397  }
398 
399  const auto newSize = a_rhs.size();
400  const auto newData = allocate(newCapacity);
401  for (size_type i = 0; i < newSize; ++i) {
402  std::construct_at(newData + i, a_rhs[i]);
403  }
404 
405  set_allocator_traits(newData, newCapacity);
406  set_size(newSize);
407  }
408 
409  BSTArray(BSTArray&&) = default;
410 
411  explicit inline BSTArray(size_type a_count)
412  {
413  if (a_count == 0) {
414  return;
415  }
416 
417  const auto newCapacity = a_count;
418  const auto newSize = a_count;
419  const auto newData = allocate(newCapacity);
420  for (size_type i = 0; i < newSize; ++i) {
421  std::construct_at(newData + i);
422  }
423 
424  set_allocator_traits(newData, newCapacity);
425  set_size(newSize);
426  }
427 
428  inline ~BSTArray() { release(); }
429 
430  inline BSTArray& operator=(const BSTArray& a_rhs)
431  {
432  if (this != std::addressof(a_rhs)) {
433  clear();
434 
435  const auto newCapacity = a_rhs.capacity();
436  change_capacity(newCapacity);
437 
438  const auto newSize = a_rhs.size();
439  set_size(newSize);
440 
441  const auto newData = data();
442  for (size_type i = 0; i < newSize; ++i) {
443  std::construct_at(newData + i, a_rhs[i]);
444  }
445  }
446  return *this;
447  }
448 
450  {
451  if (this != std::addressof(a_rhs)) {
452  release();
453 
454  const auto newCapacity = a_rhs.capacity();
455  const auto newSize = a_rhs.size();
456  const auto newData = a_rhs.data();
457 
458  set_allocator_traits(newData, newCapacity);
459  a_rhs.set_allocator_traits(0, 0);
460 
461  set_size(newSize);
462  a_rhs.set_size(0);
463  }
464  return *this;
465  }
466 
468 
469  [[nodiscard]] constexpr reference operator[](size_type a_pos) noexcept
470  {
471  assert(a_pos < size());
472  return data()[a_pos];
473  }
474 
475  [[nodiscard]] constexpr const_reference operator[](size_type a_pos) const noexcept
476  {
477  assert(a_pos < size());
478  return data()[a_pos];
479  }
480 
481  [[nodiscard]] constexpr reference front() noexcept { return operator[](0); }
482  [[nodiscard]] constexpr const_reference front() const noexcept { return operator[](0); }
483 
484  [[nodiscard]] constexpr reference back() noexcept { return operator[](size() - 1); }
485  [[nodiscard]] constexpr const_reference back() const noexcept { return operator[](size() - 1); }
486 
487  [[nodiscard]] constexpr pointer data() noexcept { return static_cast<pointer>(allocator_type::data()); }
488  [[nodiscard]] constexpr const_pointer data() const noexcept { return static_cast<const_pointer>(allocator_type::data()); }
489 
490  [[nodiscard]] constexpr iterator begin() noexcept { return empty() ? nullptr : data(); }
491  [[nodiscard]] constexpr const_iterator begin() const noexcept { return empty() ? nullptr : data(); }
492  [[nodiscard]] constexpr const_iterator cbegin() const noexcept { return begin(); }
493 
494  [[nodiscard]] constexpr iterator end() noexcept { return empty() ? nullptr : data() + size(); }
495  [[nodiscard]] constexpr const_iterator end() const noexcept { return empty() ? nullptr : data() + size(); }
496  [[nodiscard]] constexpr const_iterator cend() const noexcept { return end(); }
497 
498  [[nodiscard]] constexpr bool empty() const noexcept { return BSTArrayBase::empty(); }
499 
500  [[nodiscard]] constexpr size_type size() const noexcept { return BSTArrayBase::size(); }
501 
502  inline void reserve(size_type a_newCap)
503  {
504  if (a_newCap > capacity()) {
505  change_capacity(a_newCap);
506  }
507  }
508 
509  [[nodiscard]] constexpr size_type capacity() const noexcept { return allocator_type::capacity(); }
510 
511  inline void shrink_to_fit()
512  {
513  const auto newCapacity = size();
514  if (newCapacity != capacity()) {
515  change_capacity(newCapacity);
516  }
517  }
518 
519  inline void clear()
520  {
521  if (!empty()) {
522  change_size(0);
523  }
524  }
525 
527  {
528  auto pos = const_cast<iterator>(a_pos);
529  std::optional<iterator> result;
530  if (pos != begin()) {
531  result = pos - 1;
532  }
533 
534  for (auto prev = pos++; pos != cend(); prev = pos++) {
535  *prev = std::move(*pos);
536  }
537  pop_back();
538 
539  return result ? *result + 1 : begin();
540  }
541 
542  inline void push_back(const value_type& a_value) { emplace_back(a_value); }
543  inline void push_back(value_type&& a_value) { emplace_back(std::move(a_value)); }
544 
545  template <class... Args>
546  inline reference emplace_back(Args&&... a_args)
547  {
548  if (size() == capacity()) {
549  grow_capacity();
550  }
551 
552  set_size(size() + 1);
553  auto& elem = back();
554  std::construct_at(std::addressof(elem), std::forward<Args>(a_args)...);
555  return elem;
556  }
557 
558  inline void pop_back()
559  {
560  assert(!empty());
561  std::destroy_at(std::addressof(back()));
562  set_size(size() - 1);
563  }
564 
565  inline void resize(size_type a_count)
566  {
567  if (a_count != size()) {
568  change_size(a_count);
569  }
570  }
571 
572  inline void resize(size_type a_count, const value_type& a_value)
573  {
574  if (a_count != size()) {
575  change_size(a_count, a_value);
576  }
577  }
578 
579  private:
580  static constexpr size_type DF_CAP = 4; // beth default
581  static constexpr float GROWTH_FACTOR = 2.0; // not part of native type
582 
583  [[nodiscard]] inline pointer allocate(size_type a_num)
584  {
585  return static_cast<pointer>(allocator_type::allocate(a_num * sizeof(value_type)));
586  }
587 
588  inline void deallocate(void* a_ptr) { allocator_type::deallocate(a_ptr); }
589 
590  constexpr void set_allocator_traits(void* a_data, size_type a_capacity) noexcept
591  {
592  allocator_type::set_allocator_traits(a_data, a_capacity, sizeof(value_type));
593  }
594 
595  constexpr void set_size(size_type a_size) noexcept { BSTArrayBase::set_size(a_size); }
596 
597  inline void change_capacity(size_type a_newCapacity)
598  {
599  const auto newData = a_newCapacity > 0 ? allocate(a_newCapacity) : nullptr;
600  const auto oldData = data();
601  if (oldData) {
602  const auto oldCapacity = capacity();
603  if (newData) {
604  const auto bytesToCopy = std::min(oldCapacity, a_newCapacity) * sizeof(value_type);
605  std::memcpy(newData, oldData, bytesToCopy);
606  }
607  deallocate(oldData);
608  }
609  set_allocator_traits(newData, a_newCapacity);
610  }
611 
612  template <class... Args>
613  inline void change_size(size_type a_newSize, Args&&... a_args)
614  {
615  if (a_newSize > capacity()) {
616  grow_capacity(a_newSize);
617  }
618 
619  const auto oldSize = size();
620  if (a_newSize > oldSize) {
621  for (size_type i = oldSize; i < a_newSize; ++i) {
622  std::construct_at(data() + i, std::forward<Args>(a_args)...);
623  }
624  } else {
625  for (size_type i = a_newSize; i < oldSize; ++i) {
626  std::destroy_at(data() + i);
627  }
628  }
629 
630  set_size(a_newSize);
631  }
632 
633  inline void grow_capacity() { grow_capacity(capacity()); }
634 
635  inline void grow_capacity(size_type a_hint)
636  {
637  auto cap = a_hint;
638  cap = cap > 0 ? static_cast<size_type>(std::ceil(static_cast<float>(cap) * GROWTH_FACTOR)) : DF_CAP;
639  change_capacity(cap);
640  }
641 
642  inline void release()
643  {
644  clear();
645  change_capacity(0);
646  }
647  };
648 
649  template <class T, std::uint32_t N = 1>
651 
652  template <class T>
654 
655  template <class T>
657  {
658  public:
659  using value_type = T;
660  using size_type = std::uint32_t;
661  using pointer = value_type*;
662  using const_pointer = const value_type*;
664  using const_reference = const value_type&;
665  using iterator = pointer;
667 
668  [[nodiscard]] constexpr reference operator[](size_type a_pos) noexcept
669  {
670  assert(a_pos < _size);
671  return _data[a_pos];
672  }
673 
674  [[nodiscard]] constexpr const_reference operator[](size_type a_pos) const noexcept
675  {
676  assert(a_pos < _size);
677  return _data[a_pos];
678  }
679 
680  [[nodiscard]] constexpr reference front() noexcept { return operator[](0); }
681  [[nodiscard]] constexpr const_reference front() const noexcept { return operator[](0); }
682 
683  [[nodiscard]] constexpr reference back() noexcept { return operator[](size() - 1); }
684  [[nodiscard]] constexpr const_reference back() const noexcept { return operator[](size() - 1); }
685 
686  [[nodiscard]] constexpr pointer data() noexcept { return _data; }
687  [[nodiscard]] constexpr const_pointer data() const noexcept { return _data; }
688 
689  [[nodiscard]] constexpr iterator begin() noexcept { return empty() ? nullptr : data(); }
690  [[nodiscard]] constexpr const_iterator begin() const noexcept { return empty() ? nullptr : data(); }
691  [[nodiscard]] constexpr const_iterator cbegin() const noexcept { return begin(); }
692 
693  [[nodiscard]] constexpr iterator end() noexcept { return empty() ? nullptr : data() + size(); }
694  [[nodiscard]] constexpr const_iterator end() const noexcept { return empty() ? nullptr : data() + size(); }
695  [[nodiscard]] constexpr const_iterator cend() const noexcept { return end(); }
696 
697  [[nodiscard]] constexpr bool empty() const noexcept { return size() == 0; }
698 
699  [[nodiscard]] constexpr size_type size() const noexcept { return _size; }
700 
701  private:
702  // members
703  pointer _data{ nullptr }; // 00
704  std::uint32_t _size{ 0 }; // 08
705  };
706 
707  template <class T>
709  {
710  public:
711  using value_type = T;
712  using size_type = std::uint32_t;
713  using pointer = value_type*;
714  using const_pointer = const value_type*;
716  using const_reference = const value_type&;
717  using iterator = pointer;
719 
720  [[nodiscard]] inline reference operator[](size_type a_pos) noexcept
721  {
722  assert(a_pos < _size);
723  return data()[a_pos];
724  }
725 
726  [[nodiscard]] inline const_reference operator[](size_type a_pos) const noexcept
727  {
728  assert(a_pos < _size);
729  return data()[a_pos];
730  }
731 
732  [[nodiscard]] inline pointer data() noexcept
733  {
734  return size() > 1 ? _data.heap : std::addressof(_data.local);
735  }
736 
737  [[nodiscard]] inline const_pointer data() const noexcept
738  {
739  return size() > 1 ? _data.heap : std::addressof(_data.local);
740  }
741 
742  [[nodiscard]] inline iterator begin() noexcept { return data(); }
743  [[nodiscard]] inline const_iterator begin() const noexcept { return data(); }
744  [[nodiscard]] inline const_iterator cbegin() const noexcept { return begin(); }
745 
746  [[nodiscard]] inline iterator end() noexcept { return data() + size(); }
747  [[nodiscard]] inline const_iterator end() const noexcept { return data() + size(); }
748  [[nodiscard]] inline const_iterator cend() const noexcept { return end(); }
749 
750  [[nodiscard]] constexpr bool empty() const noexcept { return size() != 0; }
751 
752  [[nodiscard]] constexpr size_type size() const noexcept { return _size; }
753 
754  private:
755  union Data
756  {
757  ~Data(){};
758 
759  pointer heap{ 0 };
760  value_type local;
761  };
762 
763  // members
764  std::uint32_t _size{ 0 }; // 00
765  Data _data; // 08
766  };
767 }
Definition: BSTArray.h:287
BSScrapArrayAllocator & operator=(const BSScrapArrayAllocator &a_rhs)
Definition: BSTArray.h:314
constexpr BSScrapArrayAllocator() noexcept=default
constexpr size_type capacity() const noexcept
Definition: BSTArray.h:354
BSScrapArrayAllocator & operator=(BSScrapArrayAllocator &&a_rhs)
Definition: BSTArray.h:331
constexpr BSScrapArrayAllocator(BSScrapArrayAllocator &&a_rhs) noexcept
Definition: BSTArray.h:302
constexpr void * data() noexcept
Definition: BSTArray.h:351
std::uint32_t size_type
Definition: BSTArray.h:289
void deallocate(void *a_ptr)
constexpr void set_allocator_traits(void *a_data, std::uint32_t a_capacity, std::size_t) noexcept
Definition: BSTArray.h:360
constexpr const void * data() const noexcept
Definition: BSTArray.h:352
void * allocate(std::size_t a_size)
Definition: BSTArray.h:657
std::uint32_t size_type
Definition: BSTArray.h:660
T value_type
Definition: BSTArray.h:659
constexpr const_iterator begin() const noexcept
Definition: BSTArray.h:690
const value_type * const_pointer
Definition: BSTArray.h:662
constexpr const_iterator cbegin() const noexcept
Definition: BSTArray.h:691
constexpr reference operator[](size_type a_pos) noexcept
Definition: BSTArray.h:668
const value_type & const_reference
Definition: BSTArray.h:664
constexpr const_reference operator[](size_type a_pos) const noexcept
Definition: BSTArray.h:674
constexpr const_pointer data() const noexcept
Definition: BSTArray.h:687
const_pointer const_iterator
Definition: BSTArray.h:666
constexpr const_reference front() const noexcept
Definition: BSTArray.h:681
constexpr const_reference back() const noexcept
Definition: BSTArray.h:684
constexpr reference back() noexcept
Definition: BSTArray.h:683
constexpr iterator begin() noexcept
Definition: BSTArray.h:689
constexpr bool empty() const noexcept
Definition: BSTArray.h:697
pointer iterator
Definition: BSTArray.h:665
value_type & reference
Definition: BSTArray.h:663
constexpr iterator end() noexcept
Definition: BSTArray.h:693
constexpr const_iterator cend() const noexcept
Definition: BSTArray.h:695
constexpr size_type size() const noexcept
Definition: BSTArray.h:699
constexpr reference front() noexcept
Definition: BSTArray.h:680
value_type * pointer
Definition: BSTArray.h:661
constexpr pointer data() noexcept
Definition: BSTArray.h:686
constexpr const_iterator end() const noexcept
Definition: BSTArray.h:694
Definition: BSTArray.h:15
virtual bool Allocate(std::uint32_t a_num, std::uint32_t a_elemSize)=0
static constexpr auto VTABLE
Definition: BSTArray.h:18
virtual bool Reallocate(std::uint32_t a_minNewSizeInItems, std::uint32_t a_frontCopyCount, std::uint32_t a_shiftCount, std::uint32_t a_backCopyCount, std::uint32_t a_elemSize)=0
static constexpr auto RTTI
Definition: BSTArray.h:17
Definition: BSTArray.h:10
constexpr size_type size() const noexcept
Definition: BSTArray.h:41
constexpr void set_size(size_type a_size) noexcept
Definition: BSTArray.h:44
constexpr bool empty() const noexcept
Definition: BSTArray.h:40
BSTArrayBase & operator=(BSTArrayBase &&) noexcept=default
BSTArrayBase & operator=(const BSTArrayBase &) noexcept=default
constexpr BSTArrayBase() noexcept=default
std::uint32_t size_type
Definition: BSTArray.h:12
Definition: BSTArray.h:53
constexpr void * data() noexcept
Definition: BSTArray.h:114
void deallocate(void *a_ptr)
Definition: BSTArray.h:131
std::uint32_t size_type
Definition: BSTArray.h:55
void * allocate(std::size_t a_size)
Definition: BSTArray.h:120
BSTArrayHeapAllocator & operator=(BSTArrayHeapAllocator &&a_rhs)
Definition: BSTArray.h:99
~BSTArrayHeapAllocator()
Definition: BSTArray.h:76
constexpr BSTArrayHeapAllocator(BSTArrayHeapAllocator &&a_rhs) noexcept
Definition: BSTArray.h:68
constexpr void set_allocator_traits(void *a_data, std::uint32_t a_capacity, std::size_t) noexcept
Definition: BSTArray.h:133
constexpr size_type capacity() const noexcept
Definition: BSTArray.h:117
constexpr BSTArrayHeapAllocator() noexcept=default
BSTArrayHeapAllocator & operator=(const BSTArrayHeapAllocator &a_rhs)
Definition: BSTArray.h:83
constexpr const void * data() const noexcept
Definition: BSTArray.h:115
Definition: BSTArray.h:378
value_type & reference
Definition: BSTArray.h:385
const_pointer const_iterator
Definition: BSTArray.h:388
void resize(size_type a_count, const value_type &a_value)
Definition: BSTArray.h:572
void push_back(value_type &&a_value)
Definition: BSTArray.h:543
void resize(size_type a_count)
Definition: BSTArray.h:565
void pop_back()
Definition: BSTArray.h:558
constexpr pointer data() noexcept
Definition: BSTArray.h:487
iterator erase(const_iterator a_pos)
Definition: BSTArray.h:526
constexpr size_type size() const noexcept
Definition: BSTArray.h:500
constexpr reference back() noexcept
Definition: BSTArray.h:484
constexpr const_iterator cbegin() const noexcept
Definition: BSTArray.h:492
void clear()
Definition: BSTArray.h:519
constexpr reference operator[](size_type a_pos) noexcept
Definition: BSTArray.h:469
Allocator allocator_type
Definition: BSTArray.h:380
constexpr const_reference operator[](size_type a_pos) const noexcept
Definition: BSTArray.h:475
~BSTArray()
Definition: BSTArray.h:428
BSTArray & operator=(BSTArray &&a_rhs)
Definition: BSTArray.h:449
reference emplace_back(Args &&... a_args)
Definition: BSTArray.h:546
constexpr size_type capacity() const noexcept
Definition: BSTArray.h:509
BSTArray()=default
T value_type
Definition: BSTArray.h:382
constexpr const_reference back() const noexcept
Definition: BSTArray.h:485
void reserve(size_type a_newCap)
Definition: BSTArray.h:502
typename BSTArrayBase::size_type size_type
Definition: BSTArray.h:381
void shrink_to_fit()
Definition: BSTArray.h:511
const value_type & const_reference
Definition: BSTArray.h:386
constexpr const_pointer data() const noexcept
Definition: BSTArray.h:488
BSTArray(const BSTArray &a_rhs)
Definition: BSTArray.h:392
constexpr iterator end() noexcept
Definition: BSTArray.h:494
constexpr reference front() noexcept
Definition: BSTArray.h:481
BSTArray(BSTArray &&)=default
const value_type * const_pointer
Definition: BSTArray.h:384
void push_back(const value_type &a_value)
Definition: BSTArray.h:542
BSTArray(size_type a_count)
Definition: BSTArray.h:411
constexpr bool empty() const noexcept
Definition: BSTArray.h:498
value_type * pointer
Definition: BSTArray.h:383
BSTArray & operator=(const BSTArray &a_rhs)
Definition: BSTArray.h:430
constexpr const_iterator end() const noexcept
Definition: BSTArray.h:495
constexpr const_iterator begin() const noexcept
Definition: BSTArray.h:491
constexpr const_reference front() const noexcept
Definition: BSTArray.h:482
constexpr const_iterator cend() const noexcept
Definition: BSTArray.h:496
pointer iterator
Definition: BSTArray.h:387
constexpr iterator begin() noexcept
Definition: BSTArray.h:490
Definition: BSTArray.h:148
constexpr BSTSmallArrayHeapAllocator() noexcept
Definition: BSTArray.h:152
BSTSmallArrayHeapAllocator & operator=(BSTSmallArrayHeapAllocator &&a_rhs)
Definition: BSTArray.h:181
constexpr void set_allocator_traits(void *a_data, std::uint32_t a_capacity, std::size_t a_typeSize) noexcept
Definition: BSTArray.h:219
BSTSmallArrayHeapAllocator(BSTSmallArrayHeapAllocator &&a_rhs)
Definition: BSTArray.h:164
std::uint32_t size_type
Definition: BSTArray.h:150
BSTSmallArrayHeapAllocator & operator=(const BSTSmallArrayHeapAllocator &a_rhs)
Definition: BSTArray.h:173
~BSTSmallArrayHeapAllocator()
Definition: BSTArray.h:171
constexpr void * data() noexcept
Definition: BSTArray.h:191
constexpr const void * data() const noexcept
Definition: BSTArray.h:192
void * allocate(std::size_t a_size)
Definition: BSTArray.h:197
void deallocate(void *a_ptr)
Definition: BSTArray.h:212
BSTSmallArrayHeapAllocator(const BSTSmallArrayHeapAllocator &a_rhs)
Definition: BSTArray.h:157
constexpr size_type capacity() const noexcept
Definition: BSTArray.h:194
Definition: BSTArray.h:709
const value_type & const_reference
Definition: BSTArray.h:716
std::uint32_t size_type
Definition: BSTArray.h:712
const value_type * const_pointer
Definition: BSTArray.h:714
constexpr size_type size() const noexcept
Definition: BSTArray.h:752
iterator begin() noexcept
Definition: BSTArray.h:742
iterator end() noexcept
Definition: BSTArray.h:746
T value_type
Definition: BSTArray.h:711
const_iterator cbegin() const noexcept
Definition: BSTArray.h:744
const_pointer const_iterator
Definition: BSTArray.h:718
const_iterator begin() const noexcept
Definition: BSTArray.h:743
constexpr bool empty() const noexcept
Definition: BSTArray.h:750
reference operator[](size_type a_pos) noexcept
Definition: BSTArray.h:720
pointer data() noexcept
Definition: BSTArray.h:732
value_type & reference
Definition: BSTArray.h:715
pointer iterator
Definition: BSTArray.h:717
const_iterator end() const noexcept
Definition: BSTArray.h:747
const_iterator cend() const noexcept
Definition: BSTArray.h:748
value_type * pointer
Definition: BSTArray.h:713
const_reference operator[](size_type a_pos) const noexcept
Definition: BSTArray.h:726
const_pointer data() const noexcept
Definition: BSTArray.h:737
Definition: ScrapHeap.h:10
NiColor min(const NiColor &a_lhs, const NiColor &a_rhs)
Definition: ColorUtil.h:63
Definition: AbsorbEffect.h:6
void * malloc(std::size_t a_size)
Definition: MemoryManager.h:98
constexpr std::array< REL::ID, 1 > VTABLE_BSTArrayBase__IAllocatorFunctor
Definition: Offsets_VTABLE.h:9923
constexpr REL::ID RTTI_BSTArrayBase__IAllocatorFunctor(static_cast< std::uint64_t >(684604))
void free(void *a_ptr)
Definition: MemoryManager.h:187
void report_and_fail(std::string_view a_msg, std::source_location a_loc=std::source_location::current())
Definition: PCH.h:396