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