CommonLibSSE NG
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 
526  {
527  auto pos = const_cast<iterator>(a_pos);
528  std::optional<iterator> result;
529  if (pos != begin()) {
530  result = pos - 1;
531  }
532 
533  for (auto prev = pos++; pos != cend(); prev = pos++) {
534  *prev = std::move(*pos);
535  }
536  pop_back();
537 
538  return result ? *result + 1 : begin();
539  }
540 
541  inline void push_back(const value_type& a_value) { emplace_back(a_value); }
542  inline void push_back(value_type&& a_value) { emplace_back(std::move(a_value)); }
543 
544  template <class... Args>
545  inline reference emplace_back(Args&&... a_args)
546  {
547  if (size() == capacity()) {
548  grow_capacity();
549  }
550 
551  set_size(size() + 1);
552  auto& elem = back();
553  std::construct_at(std::addressof(elem), std::forward<Args>(a_args)...);
554  return elem;
555  }
556 
557  inline void pop_back()
558  {
559  assert(!empty());
560  std::destroy_at(std::addressof(back()));
561  set_size(size() - 1);
562  }
563 
564  inline void resize(size_type a_count)
565  {
566  if (a_count != size()) {
567  change_size(a_count);
568  }
569  }
570 
571  inline void resize(size_type a_count, const value_type& a_value)
572  {
573  if (a_count != size()) {
574  change_size(a_count, a_value);
575  }
576  }
577 
578  private:
579  static constexpr size_type DF_CAP = 4; // beth default
580  static constexpr float GROWTH_FACTOR = 2.0; // not part of native type
581 
582  [[nodiscard]] inline pointer allocate(size_type a_num)
583  {
584  return static_cast<pointer>(allocator_type::allocate(a_num * sizeof(value_type)));
585  }
586 
587  inline void deallocate(void* a_ptr) { allocator_type::deallocate(a_ptr); }
588 
589  constexpr void set_allocator_traits(void* a_data, size_type a_capacity) noexcept
590  {
591  allocator_type::set_allocator_traits(a_data, a_capacity, sizeof(value_type));
592  }
593 
594  constexpr void set_size(size_type a_size) noexcept { BSTArrayBase::set_size(a_size); }
595 
596  inline void change_capacity(size_type a_newCapacity)
597  {
598  const auto newData = a_newCapacity > 0 ? allocate(a_newCapacity) : nullptr;
599  const auto oldData = data();
600  if (oldData) {
601  const auto oldCapacity = capacity();
602  if (newData) {
603  const auto bytesToCopy = (std::min)(oldCapacity, a_newCapacity) * sizeof(value_type);
604  std::memcpy(newData, oldData, bytesToCopy);
605  }
606  deallocate(oldData);
607  }
608  set_allocator_traits(newData, a_newCapacity);
609  }
610 
611  template <class... Args>
612  inline void change_size(size_type a_newSize, Args&&... a_args)
613  {
614  if (a_newSize > capacity()) {
615  grow_capacity(a_newSize);
616  }
617 
618  const auto oldSize = size();
619  if (a_newSize > oldSize) {
620  for (size_type i = oldSize; i < a_newSize; ++i) {
621  std::construct_at(data() + i, std::forward<Args>(a_args)...);
622  }
623  } else {
624  for (size_type i = a_newSize; i < oldSize; ++i) {
625  std::destroy_at(data() + i);
626  }
627  }
628 
629  set_size(a_newSize);
630  }
631 
632  inline void grow_capacity() { grow_capacity(capacity()); }
633 
634  inline void grow_capacity(size_type a_hint)
635  {
636  auto cap = a_hint;
637  cap = cap > 0 ? static_cast<size_type>(std::ceil(static_cast<float>(cap) * GROWTH_FACTOR)) : DF_CAP;
638  change_capacity(cap);
639  }
640 
641  inline void release()
642  {
643  clear();
644  change_capacity(0);
645  }
646  };
647 
648  template <class T, std::uint32_t N = 1>
650 
651  template <class T>
653 
654  template <class T>
656  {
657  public:
658  using value_type = T;
659  using size_type = std::uint32_t;
660  using pointer = value_type*;
661  using const_pointer = const value_type*;
663  using const_reference = const value_type&;
664  using iterator = pointer;
666 
667  [[nodiscard]] constexpr reference operator[](size_type a_pos) noexcept
668  {
669  assert(a_pos < _size);
670  return _data[a_pos];
671  }
672 
673  [[nodiscard]] constexpr const_reference operator[](size_type a_pos) const noexcept
674  {
675  assert(a_pos < _size);
676  return _data[a_pos];
677  }
678 
679  [[nodiscard]] constexpr reference front() noexcept { return operator[](0); }
680  [[nodiscard]] constexpr const_reference front() const noexcept { return operator[](0); }
681 
682  [[nodiscard]] constexpr reference back() noexcept { return operator[](size() - 1); }
683  [[nodiscard]] constexpr const_reference back() const noexcept { return operator[](size() - 1); }
684 
685  [[nodiscard]] constexpr pointer data() noexcept { return _data; }
686  [[nodiscard]] constexpr const_pointer data() const noexcept { return _data; }
687 
688  [[nodiscard]] constexpr iterator begin() noexcept { return empty() ? nullptr : data(); }
689  [[nodiscard]] constexpr const_iterator begin() const noexcept { return empty() ? nullptr : data(); }
690  [[nodiscard]] constexpr const_iterator cbegin() const noexcept { return begin(); }
691 
692  [[nodiscard]] constexpr iterator end() noexcept { return empty() ? nullptr : data() + size(); }
693  [[nodiscard]] constexpr const_iterator end() const noexcept { return empty() ? nullptr : data() + size(); }
694  [[nodiscard]] constexpr const_iterator cend() const noexcept { return end(); }
695 
696  [[nodiscard]] constexpr bool empty() const noexcept { return size() == 0; }
697 
698  [[nodiscard]] constexpr size_type size() const noexcept { return _size; }
699 
700  private:
701  // members
702  pointer _data{ nullptr }; // 00
703  std::uint32_t _size{ 0 }; // 08
704  };
705 
706  template <class T>
708  {
709  public:
710  using value_type = T;
711  using size_type = std::uint32_t;
712  using pointer = value_type*;
713  using const_pointer = const value_type*;
715  using const_reference = const value_type&;
716  using iterator = pointer;
718 
719  [[nodiscard]] inline reference operator[](size_type a_pos) noexcept
720  {
721  assert(a_pos < _size);
722  return data()[a_pos];
723  }
724 
725  [[nodiscard]] inline const_reference operator[](size_type a_pos) const noexcept
726  {
727  assert(a_pos < _size);
728  return data()[a_pos];
729  }
730 
731  [[nodiscard]] inline pointer data() noexcept
732  {
733  return size() > 1 ? _data.heap : std::addressof(_data.local);
734  }
735 
736  [[nodiscard]] inline const_pointer data() const noexcept
737  {
738  return size() > 1 ? _data.heap : std::addressof(_data.local);
739  }
740 
741  [[nodiscard]] inline iterator begin() noexcept { return data(); }
742  [[nodiscard]] inline const_iterator begin() const noexcept { return data(); }
743  [[nodiscard]] inline const_iterator cbegin() const noexcept { return begin(); }
744 
745  [[nodiscard]] inline iterator end() noexcept { return data() + size(); }
746  [[nodiscard]] inline const_iterator end() const noexcept { return data() + size(); }
747  [[nodiscard]] inline const_iterator cend() const noexcept { return end(); }
748 
749  [[nodiscard]] constexpr bool empty() const noexcept { return size() != 0; }
750 
751  [[nodiscard]] constexpr size_type size() const noexcept { return _size; }
752 
753  private:
754  union Data
755  {
756  ~Data(){};
757 
758  pointer heap{ 0 };
759  value_type local;
760  };
761 
762  // members
763  std::uint32_t _size{ 0 }; // 00
764  Data _data; // 08
765  };
766 }
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:656
std::uint32_t size_type
Definition: BSTArray.h:659
T value_type
Definition: BSTArray.h:658
constexpr const_iterator begin() const noexcept
Definition: BSTArray.h:689
const value_type * const_pointer
Definition: BSTArray.h:661
constexpr const_iterator cbegin() const noexcept
Definition: BSTArray.h:690
constexpr reference operator[](size_type a_pos) noexcept
Definition: BSTArray.h:667
const value_type & const_reference
Definition: BSTArray.h:663
constexpr const_reference operator[](size_type a_pos) const noexcept
Definition: BSTArray.h:673
constexpr const_pointer data() const noexcept
Definition: BSTArray.h:686
const_pointer const_iterator
Definition: BSTArray.h:665
constexpr const_reference front() const noexcept
Definition: BSTArray.h:680
constexpr const_reference back() const noexcept
Definition: BSTArray.h:683
constexpr reference back() noexcept
Definition: BSTArray.h:682
constexpr iterator begin() noexcept
Definition: BSTArray.h:688
constexpr bool empty() const noexcept
Definition: BSTArray.h:696
pointer iterator
Definition: BSTArray.h:664
value_type & reference
Definition: BSTArray.h:662
constexpr iterator end() noexcept
Definition: BSTArray.h:692
constexpr const_iterator cend() const noexcept
Definition: BSTArray.h:694
constexpr size_type size() const noexcept
Definition: BSTArray.h:698
constexpr reference front() noexcept
Definition: BSTArray.h:679
value_type * pointer
Definition: BSTArray.h:660
constexpr pointer data() noexcept
Definition: BSTArray.h:685
constexpr const_iterator end() const noexcept
Definition: BSTArray.h:693
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:571
void push_back(value_type &&a_value)
Definition: BSTArray.h:542
void resize(size_type a_count)
Definition: BSTArray.h:564
void pop_back()
Definition: BSTArray.h:557
constexpr pointer data() noexcept
Definition: BSTArray.h:486
iterator erase(const_iterator a_pos)
Definition: BSTArray.h:525
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:545
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:541
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
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
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:708
const value_type & const_reference
Definition: BSTArray.h:715
std::uint32_t size_type
Definition: BSTArray.h:711
const value_type * const_pointer
Definition: BSTArray.h:713
constexpr size_type size() const noexcept
Definition: BSTArray.h:751
iterator begin() noexcept
Definition: BSTArray.h:741
iterator end() noexcept
Definition: BSTArray.h:745
T value_type
Definition: BSTArray.h:710
const_iterator cbegin() const noexcept
Definition: BSTArray.h:743
const_pointer const_iterator
Definition: BSTArray.h:717
const_iterator begin() const noexcept
Definition: BSTArray.h:742
constexpr bool empty() const noexcept
Definition: BSTArray.h:749
reference operator[](size_type a_pos) noexcept
Definition: BSTArray.h:719
pointer data() noexcept
Definition: BSTArray.h:731
value_type & reference
Definition: BSTArray.h:714
pointer iterator
Definition: BSTArray.h:716
const_iterator end() const noexcept
Definition: BSTArray.h:746
const_iterator cend() const noexcept
Definition: BSTArray.h:747
value_type * pointer
Definition: BSTArray.h:712
const_reference operator[](size_type a_pos) const noexcept
Definition: BSTArray.h:725
const_pointer data() const noexcept
Definition: BSTArray.h:736
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
void free(void *a_ptr)
Definition: MemoryManager.h:187
constexpr REL::VariantID RTTI_BSTArrayBase__IAllocatorFunctor(684604, 392254, 0x1ed7480)
void report_and_fail(std::string_view a_msg, std::source_location a_loc=std::source_location::current())
Definition: PCH.h:660