CommonLibVR
NiTSet.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/N/NiTCollection.h"
4 
5 namespace RE
6 {
7  template <class T, class Allocator>
8  class NiTSet
9  {
10  public:
11  using value_type = T;
12  using allocator_type = Allocator;
13  using size_type = std::uint32_t;
15  using const_reference = const value_type&;
16  using iterator = T*;
17  using const_iterator = const T*;
18 
19  NiTSet(std::uint32_t a_initialSize = 0) :
20  _data(0),
21  _capacity(a_initialSize),
22  _size(0)
23  {
24  if (_capacity > 0) {
25  _data = allocator_type::Allocate(_capacity);
26  }
27  }
28 
30  {
32  }
33 
35  {
36  assert(a_pos < size());
37  return _data[a_pos];
38  }
39 
41  {
42  assert(a_pos < size());
43  return _data[a_pos];
44  }
45 
47  {
48  return operator[](0);
49  }
50 
51  [[nodiscard]] const_reference front() const
52  {
53  return operator[](0);
54  }
55 
57  {
58  return operator[](size() - 1);
59  }
60 
61  [[nodiscard]] const_reference back() const
62  {
63  return operator[](size() - 1);
64  }
65 
67  {
68  return _data;
69  }
70 
71  [[nodiscard]] const_iterator begin() const
72  {
73  return _data;
74  }
75 
76  [[nodiscard]] const_iterator cbegin() const
77  {
78  return _data;
79  }
80 
82  {
83  return _data + _size;
84  }
85 
86  [[nodiscard]] const_iterator end() const
87  {
88  return _data + _size;
89  }
90 
91  [[nodiscard]] const_iterator cend() const
92  {
93  return _data + _size;
94  }
95 
96  [[nodiscard]] bool empty() const
97  {
98  return _capacity == 0;
99  }
100 
101  [[nodiscard]] size_type size() const
102  {
103  return _size;
104  }
105 
106  [[nodiscard]] size_type capacity() const
107  {
108  return _capacity;
109  }
110 
111  private:
112  T* _data; // 00
113  std::uint32_t _capacity; // 08
114  std::uint32_t _size; // 0C
115  };
116  static_assert(sizeof(NiTSet<void*, NiTMallocInterface<void*>>) == 0x10);
117 
118  template <class T>
119  class NiTObjectSet : public NiTSet<T, NiTNewInterface<T>>
120  {
121  public:
122  NiTObjectSet(std::uint32_t a_initialSize = 0) :
123  NiTSet<T, NiTNewInterface<T>>(a_initialSize)
124  {}
125  };
126  static_assert(sizeof(NiTObjectSet<void*>) == 0x10);
127 
128  template <class T>
129  class NiTPrimitiveSet : public NiTSet<T, NiTMallocInterface<T>>
130  {
131  public:
132  NiTPrimitiveSet(std::uint32_t a_initialSize = 0) :
133  NiTSet<T, NiTMallocInterface<T>>(a_initialSize)
134  {}
135  };
136  static_assert(sizeof(NiTPrimitiveSet<void*>) == 0x10);
137 }
Definition: NiTCollection.h:32
Definition: NiTCollection.h:47
Definition: NiTSet.h:120
NiTObjectSet(std::uint32_t a_initialSize=0)
Definition: NiTSet.h:122
Definition: NiTSet.h:130
NiTPrimitiveSet(std::uint32_t a_initialSize=0)
Definition: NiTSet.h:132
Definition: NiTSet.h:9
T * iterator
Definition: NiTSet.h:16
bool empty() const
Definition: NiTSet.h:96
const_iterator cbegin() const
Definition: NiTSet.h:76
size_type size() const
Definition: NiTSet.h:101
reference back()
Definition: NiTSet.h:56
reference operator[](size_type a_pos)
Definition: NiTSet.h:34
const_reference front() const
Definition: NiTSet.h:51
~NiTSet()
Definition: NiTSet.h:29
std::uint32_t size_type
Definition: NiTSet.h:13
size_type capacity() const
Definition: NiTSet.h:106
const_reference operator[](size_type a_pos) const
Definition: NiTSet.h:40
iterator end()
Definition: NiTSet.h:81
Allocator allocator_type
Definition: NiTSet.h:12
const_iterator cend() const
Definition: NiTSet.h:91
const_iterator end() const
Definition: NiTSet.h:86
T value_type
Definition: NiTSet.h:11
reference front()
Definition: NiTSet.h:46
iterator begin()
Definition: NiTSet.h:66
const value_type & const_reference
Definition: NiTSet.h:15
value_type & reference
Definition: NiTSet.h:14
const T * const_iterator
Definition: NiTSet.h:17
const_reference back() const
Definition: NiTSet.h:61
NiTSet(std::uint32_t a_initialSize=0)
Definition: NiTSet.h:19
const_iterator begin() const
Definition: NiTSet.h:71
constexpr REL::ID Allocate(static_cast< std::uint64_t >(66859))
constexpr REL::ID Deallocate(static_cast< std::uint64_t >(66861))
Definition: AbsorbEffect.h:6