CommonLibSSE (powerof3)
Loading...
Searching...
No Matches
BSTArray.h
Go to the documentation of this file.
1#pragma once
2
4
5namespace 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 {
79 _data = nullptr;
80 _capacity = 0;
81 }
82
84 {
85 if (this != std::addressof(a_rhs)) {
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;
384 using const_pointer = const value_type*;
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 inline BSTArray(const std::initializer_list<T> a_list)
410 {
411 if (a_list.size() == 0) {
412 return;
413 }
414
415 const auto newSize = a_list.size();
416 const auto newData = allocate(newSize);
417 size_type i = 0;
418 for (const auto& elem : a_list) {
419 std::construct_at(newData + i++, elem);
420 }
421
422 set_allocator_traits(newData, newSize);
423 set_size(newSize);
424 }
425
426 BSTArray(BSTArray&&) = default;
427
428 explicit inline BSTArray(size_type a_count)
429 {
430 if (a_count == 0) {
431 return;
432 }
433
434 const auto newCapacity = a_count;
435 const auto newSize = a_count;
436 const auto newData = allocate(newCapacity);
437 for (size_type i = 0; i < newSize; ++i) {
438 std::construct_at(newData + i);
439 }
440
441 set_allocator_traits(newData, newCapacity);
442 set_size(newSize);
443 }
444
445 inline ~BSTArray() { release(); }
446
447 inline BSTArray& operator=(const BSTArray& a_rhs)
448 {
449 if (this != std::addressof(a_rhs)) {
450 clear();
451
452 const auto newCapacity = a_rhs.capacity();
453 change_capacity(newCapacity);
454
455 const auto newSize = a_rhs.size();
456 set_size(newSize);
457
458 const auto newData = data();
459 for (size_type i = 0; i < newSize; ++i) {
460 std::construct_at(newData + i, a_rhs[i]);
461 }
462 }
463 return *this;
464 }
465
467 {
468 if (this != std::addressof(a_rhs)) {
469 release();
470
471 const auto newCapacity = a_rhs.capacity();
472 const auto newSize = a_rhs.size();
473 const auto newData = a_rhs.data();
474
475 set_allocator_traits(newData, newCapacity);
476 a_rhs.set_allocator_traits(0, 0);
477
478 set_size(newSize);
479 a_rhs.set_size(0);
480 }
481 return *this;
482 }
483
485
486 [[nodiscard]] constexpr reference operator[](size_type a_pos) noexcept
487 {
488 assert(a_pos < size());
489 return data()[a_pos];
490 }
491
492 [[nodiscard]] constexpr const_reference operator[](size_type a_pos) const noexcept
493 {
494 assert(a_pos < size());
495 return data()[a_pos];
496 }
497
498 [[nodiscard]] constexpr reference front() noexcept { return operator[](0); }
499 [[nodiscard]] constexpr const_reference front() const noexcept { return operator[](0); }
500
501 [[nodiscard]] constexpr reference back() noexcept { return operator[](size() - 1); }
502 [[nodiscard]] constexpr const_reference back() const noexcept { return operator[](size() - 1); }
503
504 [[nodiscard]] constexpr pointer data() noexcept { return static_cast<pointer>(allocator_type::data()); }
505 [[nodiscard]] constexpr const_pointer data() const noexcept { return static_cast<const_pointer>(allocator_type::data()); }
506
507 [[nodiscard]] constexpr iterator begin() noexcept { return empty() ? nullptr : data(); }
508 [[nodiscard]] constexpr const_iterator begin() const noexcept { return empty() ? nullptr : data(); }
509 [[nodiscard]] constexpr const_iterator cbegin() const noexcept { return begin(); }
510
511 [[nodiscard]] constexpr iterator end() noexcept { return empty() ? nullptr : data() + size(); }
512 [[nodiscard]] constexpr const_iterator end() const noexcept { return empty() ? nullptr : data() + size(); }
513 [[nodiscard]] constexpr const_iterator cend() const noexcept { return end(); }
514
515 [[nodiscard]] constexpr bool empty() const noexcept { return BSTArrayBase::empty(); }
516
517 [[nodiscard]] constexpr size_type size() const noexcept { return BSTArrayBase::size(); }
518
519 inline void reserve(size_type a_newCap)
520 {
521 if (a_newCap > capacity()) {
522 change_capacity(a_newCap);
523 }
524 }
525
526 [[nodiscard]] constexpr size_type capacity() const noexcept { return allocator_type::capacity(); }
527
528 inline void shrink_to_fit()
529 {
530 const auto newCapacity = size();
531 if (newCapacity != capacity()) {
532 change_capacity(newCapacity);
533 }
534 }
535
536 inline void clear()
537 {
538 if (!empty()) {
539 change_size(0);
540 }
541 }
542
544 {
545 auto pos = const_cast<iterator>(a_pos);
546 std::optional<iterator> result;
547 if (pos != begin()) {
548 result = pos - 1;
549 }
550
551 for (auto prev = pos++; pos != cend(); prev = pos++) {
552 *prev = std::move(*pos);
553 }
554 pop_back();
555
556 return result ? *result + 1 : begin();
557 }
558
559 inline void push_back(const value_type& a_value) { emplace_back(a_value); }
560 inline void push_back(value_type&& a_value) { emplace_back(std::move(a_value)); }
561
562 template <class... Args>
563 inline reference emplace_back(Args&&... a_args)
564 {
565 if (size() == capacity()) {
566 grow_capacity();
567 }
568
569 set_size(size() + 1);
570 auto& elem = back();
571 std::construct_at(std::addressof(elem), std::forward<Args>(a_args)...);
572 return elem;
573 }
574
575 inline void insert(const_iterator position, const value_type& a_value) { emplace(position, a_value); }
576 inline void insert(const_iterator position, value_type&& a_value) { emplace(position, std::move(a_value)); }
577
578 inline void push_front(const value_type& a_value) { emplace(cbegin(), a_value); }
579 inline void push_front(value_type&& a_value) { emplace(cbegin(), std::move(a_value)); }
580
581 template <class... Args>
582 inline reference emplace(const_iterator position, Args&&... a_args)
583 {
584 assert(position >= cbegin() && position <= cend());
585
586 if (position == cend()) {
587 return emplace_back(std::forward<Args>(a_args)...);
588 }
589
590 pointer oldData;
591 pointer newData;
592 size_type newCapacity;
593
594 if (size() == capacity()) {
595 newCapacity = next_capacity();
596 newData = allocate(newCapacity); // manually grow capacity to avoid unnecessary memcpy from change_capacity
597 oldData = data();
598 } else {
599 newData = data();
600 oldData = nullptr;
601 newCapacity = capacity();
602 }
603
604 const auto headPartToCopy = position - cbegin();
605 const auto tailPartToCopy = cend() - position;
606 const auto tailBytesToCopy = tailPartToCopy * sizeof(T);
607 std::memcpy(newData + headPartToCopy + 1, cend() - tailPartToCopy, tailBytesToCopy);
608 std::construct_at(newData + headPartToCopy, std::forward<Args>(a_args)...);
609 const auto headBytesToCopy = headPartToCopy * sizeof(T);
610 std::memcpy(newData, cbegin(), headBytesToCopy);
611
612 if (oldData) {
613 deallocate(oldData);
614 set_allocator_traits(newData, newCapacity);
615 }
616
617 set_size(size() + 1);
618
619 return *(newData + headPartToCopy);
620 }
621
622 inline void pop_back()
623 {
624 assert(!empty());
625 std::destroy_at(std::addressof(back()));
626 set_size(size() - 1);
627 }
628
629 inline void resize(size_type a_count)
630 {
631 if (a_count != size()) {
632 change_size(a_count);
633 }
634 }
635
636 inline void resize(size_type a_count, const value_type& a_value)
637 {
638 if (a_count != size()) {
639 change_size(a_count, a_value);
640 }
641 }
642
643 private:
644 static constexpr size_type DF_CAP = 4; // beth default
645 static constexpr float GROWTH_FACTOR = 2.0; // not part of native type
646
647 [[nodiscard]] inline pointer allocate(size_type a_num)
648 {
649 return static_cast<pointer>(allocator_type::allocate(a_num * sizeof(value_type)));
650 }
651
652 inline void deallocate(void* a_ptr) { allocator_type::deallocate(a_ptr); }
653
654 constexpr void set_allocator_traits(void* a_data, size_type a_capacity) noexcept
655 {
656 allocator_type::set_allocator_traits(a_data, a_capacity, sizeof(value_type));
657 }
658
659 constexpr void set_size(size_type a_size) noexcept { BSTArrayBase::set_size(a_size); }
660
661 inline void change_capacity(size_type a_newCapacity)
662 {
663 const auto newData = a_newCapacity > 0 ? allocate(a_newCapacity) : nullptr;
664 const auto oldData = data();
665 if (oldData) {
666 const auto oldCapacity = capacity();
667 if (newData) {
668 const auto bytesToCopy = std::min(oldCapacity, a_newCapacity) * sizeof(value_type);
669 std::memcpy(newData, oldData, bytesToCopy);
670 }
671 deallocate(oldData);
672 }
673 set_allocator_traits(newData, a_newCapacity);
674 }
675
676 template <class... Args>
677 inline void change_size(size_type a_newSize, Args&&... a_args)
678 {
679 if (a_newSize > capacity()) {
680 grow_capacity(a_newSize);
681 }
682
683 const auto oldSize = size();
684 if (a_newSize > oldSize) {
685 for (size_type i = oldSize; i < a_newSize; ++i) {
686 std::construct_at(data() + i, std::forward<Args>(a_args)...);
687 }
688 } else {
689 for (size_type i = a_newSize; i < oldSize; ++i) {
690 std::destroy_at(data() + i);
691 }
692 }
693
694 set_size(a_newSize);
695 }
696
699 [[nodiscard]] inline size_type next_capacity() const { return next_capacity(capacity()); }
700
703 inline size_type next_capacity(size_type a_hint) const
704 {
705 auto cap = a_hint;
706 cap = cap > 0 ? static_cast<size_type>(std::ceil(static_cast<float>(cap) * GROWTH_FACTOR)) : DF_CAP;
707 return cap;
708 }
709
710 inline void grow_capacity() { grow_capacity(capacity()); }
711
712 inline void grow_capacity(size_type a_hint)
713 {
714 change_capacity(next_capacity(a_hint));
715 }
716
717 inline void release()
718 {
719 clear();
720 change_capacity(0);
721 }
722 };
723
724 template <class T, std::uint32_t N = 1>
726
727 template <class T>
729
730 template <class T>
732 {
733 public:
734 using value_type = T;
735 using size_type = std::uint32_t;
737 using const_pointer = const value_type*;
742
743 [[nodiscard]] constexpr reference operator[](size_type a_pos) noexcept
744 {
745 assert(a_pos < _size);
746 return _data[a_pos];
747 }
748
749 [[nodiscard]] constexpr const_reference operator[](size_type a_pos) const noexcept
750 {
751 assert(a_pos < _size);
752 return _data[a_pos];
753 }
754
755 [[nodiscard]] constexpr reference front() noexcept { return operator[](0); }
756 [[nodiscard]] constexpr const_reference front() const noexcept { return operator[](0); }
757
758 [[nodiscard]] constexpr reference back() noexcept { return operator[](size() - 1); }
759 [[nodiscard]] constexpr const_reference back() const noexcept { return operator[](size() - 1); }
760
761 [[nodiscard]] constexpr pointer data() noexcept { return _data; }
762 [[nodiscard]] constexpr const_pointer data() const noexcept { return _data; }
763
764 [[nodiscard]] constexpr iterator begin() noexcept { return empty() ? nullptr : data(); }
765 [[nodiscard]] constexpr const_iterator begin() const noexcept { return empty() ? nullptr : data(); }
766 [[nodiscard]] constexpr const_iterator cbegin() const noexcept { return begin(); }
767
768 [[nodiscard]] constexpr iterator end() noexcept { return empty() ? nullptr : data() + size(); }
769 [[nodiscard]] constexpr const_iterator end() const noexcept { return empty() ? nullptr : data() + size(); }
770 [[nodiscard]] constexpr const_iterator cend() const noexcept { return end(); }
771
772 [[nodiscard]] constexpr bool empty() const noexcept { return size() == 0; }
773
774 [[nodiscard]] constexpr size_type size() const noexcept { return _size; }
775
776 private:
777 // members
778 pointer _data{ nullptr }; // 00
779 std::uint32_t _size{ 0 }; // 08
780 };
781
782 template <class T>
784 {
785 public:
786 using value_type = T;
787 using size_type = std::uint32_t;
789 using const_pointer = const value_type*;
794
795 [[nodiscard]] inline reference operator[](size_type a_pos) noexcept
796 {
797 assert(a_pos < _size);
798 return data()[a_pos];
799 }
800
801 [[nodiscard]] inline const_reference operator[](size_type a_pos) const noexcept
802 {
803 assert(a_pos < _size);
804 return data()[a_pos];
805 }
806
807 [[nodiscard]] inline pointer data() noexcept
808 {
809 return size() > 1 ? _data.heap : std::addressof(_data.local);
810 }
811
812 [[nodiscard]] inline const_pointer data() const noexcept
813 {
814 return size() > 1 ? _data.heap : std::addressof(_data.local);
815 }
816
817 [[nodiscard]] inline iterator begin() noexcept { return data(); }
818 [[nodiscard]] inline const_iterator begin() const noexcept { return data(); }
819 [[nodiscard]] inline const_iterator cbegin() const noexcept { return begin(); }
820
821 [[nodiscard]] inline iterator end() noexcept { return data() + size(); }
822 [[nodiscard]] inline const_iterator end() const noexcept { return data() + size(); }
823 [[nodiscard]] inline const_iterator cend() const noexcept { return end(); }
824
825 [[nodiscard]] constexpr bool empty() const noexcept { return size() != 0; }
826
827 [[nodiscard]] constexpr size_type size() const noexcept { return _size; }
828
829 private:
830 union Data
831 {
832 ~Data(){};
833
834 pointer heap{ 0 };
835 value_type local;
836 };
837
838 // members
839 std::uint32_t _size{ 0 }; // 00
840 Data _data; // 08
841 };
842}
Definition BSTArray.h:287
BSScrapArrayAllocator & operator=(const BSScrapArrayAllocator &a_rhs)
Definition BSTArray.h:314
constexpr BSScrapArrayAllocator() noexcept=default
constexpr const void * data() const noexcept
Definition BSTArray.h:352
constexpr void * data() noexcept
Definition BSTArray.h:351
constexpr size_type capacity() const noexcept
Definition BSTArray.h:354
constexpr BSScrapArrayAllocator(BSScrapArrayAllocator &&a_rhs) noexcept
Definition BSTArray.h:302
std::uint32_t size_type
Definition BSTArray.h:289
BSScrapArrayAllocator & operator=(BSScrapArrayAllocator &&a_rhs)
Definition BSTArray.h:331
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
void * allocate(std::size_t a_size)
Definition BSTArray.h:732
std::uint32_t size_type
Definition BSTArray.h:735
T value_type
Definition BSTArray.h:734
constexpr const_iterator begin() const noexcept
Definition BSTArray.h:765
const value_type * const_pointer
Definition BSTArray.h:737
constexpr const_iterator cbegin() const noexcept
Definition BSTArray.h:766
constexpr reference operator[](size_type a_pos) noexcept
Definition BSTArray.h:743
const value_type & const_reference
Definition BSTArray.h:739
constexpr const_reference operator[](size_type a_pos) const noexcept
Definition BSTArray.h:749
constexpr const_pointer data() const noexcept
Definition BSTArray.h:762
const_pointer const_iterator
Definition BSTArray.h:741
constexpr const_reference front() const noexcept
Definition BSTArray.h:756
constexpr const_reference back() const noexcept
Definition BSTArray.h:759
constexpr reference back() noexcept
Definition BSTArray.h:758
constexpr iterator begin() noexcept
Definition BSTArray.h:764
constexpr bool empty() const noexcept
Definition BSTArray.h:772
pointer iterator
Definition BSTArray.h:740
value_type & reference
Definition BSTArray.h:738
constexpr iterator end() noexcept
Definition BSTArray.h:768
constexpr const_iterator cend() const noexcept
Definition BSTArray.h:770
constexpr size_type size() const noexcept
Definition BSTArray.h:774
constexpr reference front() noexcept
Definition BSTArray.h:755
value_type * pointer
Definition BSTArray.h:736
constexpr pointer data() noexcept
Definition BSTArray.h:761
constexpr const_iterator end() const noexcept
Definition BSTArray.h:769
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
BSTArrayBase & operator=(BSTArrayBase &&) noexcept=default
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
constexpr BSTArrayBase() noexcept=default
BSTArrayBase & operator=(const BSTArrayBase &) noexcept=default
std::uint32_t size_type
Definition BSTArray.h:12
Definition BSTArray.h:53
void deallocate(void *a_ptr)
Definition BSTArray.h:131
std::uint32_t size_type
Definition BSTArray.h:55
constexpr void * data() noexcept
Definition BSTArray.h:114
BSTArrayHeapAllocator & operator=(BSTArrayHeapAllocator &&a_rhs)
Definition BSTArray.h:99
BSTArrayHeapAllocator & operator=(const BSTArrayHeapAllocator &a_rhs)
Definition BSTArray.h:83
constexpr const void * data() const noexcept
Definition BSTArray.h:115
void * allocate(std::size_t a_size)
Definition BSTArray.h:120
~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
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:636
void push_back(value_type &&a_value)
Definition BSTArray.h:560
void resize(size_type a_count)
Definition BSTArray.h:629
void pop_back()
Definition BSTArray.h:622
constexpr pointer data() noexcept
Definition BSTArray.h:504
iterator erase(const_iterator a_pos)
Definition BSTArray.h:543
constexpr size_type size() const noexcept
Definition BSTArray.h:517
constexpr reference back() noexcept
Definition BSTArray.h:501
constexpr const_iterator cbegin() const noexcept
Definition BSTArray.h:509
void clear()
Definition BSTArray.h:536
reference emplace(const_iterator position, Args &&... a_args)
Definition BSTArray.h:582
constexpr reference operator[](size_type a_pos) noexcept
Definition BSTArray.h:486
Allocator allocator_type
Definition BSTArray.h:380
constexpr const_reference operator[](size_type a_pos) const noexcept
Definition BSTArray.h:492
~BSTArray()
Definition BSTArray.h:445
reference emplace_back(Args &&... a_args)
Definition BSTArray.h:563
constexpr size_type capacity() const noexcept
Definition BSTArray.h:526
BSTArray()=default
T value_type
Definition BSTArray.h:382
constexpr const_reference back() const noexcept
Definition BSTArray.h:502
void reserve(size_type a_newCap)
Definition BSTArray.h:519
void insert(const_iterator position, value_type &&a_value)
Definition BSTArray.h:576
typename BSTArrayBase::size_type size_type
Definition BSTArray.h:381
void shrink_to_fit()
Definition BSTArray.h:528
const value_type & const_reference
Definition BSTArray.h:386
constexpr const_pointer data() const noexcept
Definition BSTArray.h:505
BSTArray(const BSTArray &a_rhs)
Definition BSTArray.h:392
constexpr iterator end() noexcept
Definition BSTArray.h:511
BSTArray(const std::initializer_list< T > a_list)
Definition BSTArray.h:409
BSTArray & operator=(const BSTArray &a_rhs)
Definition BSTArray.h:447
constexpr reference front() noexcept
Definition BSTArray.h:498
BSTArray & operator=(BSTArray &&a_rhs)
Definition BSTArray.h:466
BSTArray(BSTArray &&)=default
const value_type * const_pointer
Definition BSTArray.h:384
void push_back(const value_type &a_value)
Definition BSTArray.h:559
BSTArray(size_type a_count)
Definition BSTArray.h:428
constexpr bool empty() const noexcept
Definition BSTArray.h:515
value_type * pointer
Definition BSTArray.h:383
void insert(const_iterator position, const value_type &a_value)
Definition BSTArray.h:575
void push_front(value_type &&a_value)
Definition BSTArray.h:579
constexpr const_iterator end() const noexcept
Definition BSTArray.h:512
constexpr const_iterator begin() const noexcept
Definition BSTArray.h:508
void push_front(const value_type &a_value)
Definition BSTArray.h:578
constexpr const_reference front() const noexcept
Definition BSTArray.h:499
constexpr const_iterator cend() const noexcept
Definition BSTArray.h:513
pointer iterator
Definition BSTArray.h:387
constexpr iterator begin() noexcept
Definition BSTArray.h:507
Definition BSTArray.h:148
constexpr BSTSmallArrayHeapAllocator() noexcept
Definition BSTArray.h:152
constexpr void set_allocator_traits(void *a_data, std::uint32_t a_capacity, std::size_t a_typeSize) noexcept
Definition BSTArray.h:219
constexpr void * data() noexcept
Definition BSTArray.h:191
BSTSmallArrayHeapAllocator(BSTSmallArrayHeapAllocator &&a_rhs)
Definition BSTArray.h:164
std::uint32_t size_type
Definition BSTArray.h:150
BSTSmallArrayHeapAllocator & operator=(BSTSmallArrayHeapAllocator &&a_rhs)
Definition BSTArray.h:181
BSTSmallArrayHeapAllocator & operator=(const BSTSmallArrayHeapAllocator &a_rhs)
Definition BSTArray.h:173
void * allocate(std::size_t a_size)
Definition BSTArray.h:197
~BSTSmallArrayHeapAllocator()
Definition BSTArray.h:171
void deallocate(void *a_ptr)
Definition BSTArray.h:212
BSTSmallArrayHeapAllocator(const BSTSmallArrayHeapAllocator &a_rhs)
Definition BSTArray.h:157
constexpr const void * data() const noexcept
Definition BSTArray.h:192
constexpr size_type capacity() const noexcept
Definition BSTArray.h:194
Definition BSTArray.h:784
const value_type & const_reference
Definition BSTArray.h:791
std::uint32_t size_type
Definition BSTArray.h:787
const value_type * const_pointer
Definition BSTArray.h:789
constexpr size_type size() const noexcept
Definition BSTArray.h:827
iterator begin() noexcept
Definition BSTArray.h:817
iterator end() noexcept
Definition BSTArray.h:821
T value_type
Definition BSTArray.h:786
const_iterator cbegin() const noexcept
Definition BSTArray.h:819
const_pointer const_iterator
Definition BSTArray.h:793
const_iterator begin() const noexcept
Definition BSTArray.h:818
constexpr bool empty() const noexcept
Definition BSTArray.h:825
reference operator[](size_type a_pos) noexcept
Definition BSTArray.h:795
pointer data() noexcept
Definition BSTArray.h:807
value_type & reference
Definition BSTArray.h:790
pointer iterator
Definition BSTArray.h:792
const_iterator end() const noexcept
Definition BSTArray.h:822
const_iterator cend() const noexcept
Definition BSTArray.h:823
value_type * pointer
Definition BSTArray.h:788
const_reference operator[](size_type a_pos) const noexcept
Definition BSTArray.h:801
const_pointer data() const noexcept
Definition BSTArray.h:812
Definition ScrapHeap.h:10
Definition AbsorbEffect.h:6
T * malloc()
Definition MemoryManager.h:113
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:397