18 typedef std::vector<T> base_class_type;
19 typedef typename base_class_type::iterator iterator;
20 typedef typename base_class_type::const_iterator const_iterator;
22 typedef typename base_class_type::reverse_iterator reverse_iterator;
23 typedef typename base_class_type::const_reverse_iterator const_reverse_iterator;
25 iterator begin() {
return m_data.begin(); }
26 const_iterator begin()
const {
return m_data.begin(); }
28 iterator end() {
return m_data.end(); }
29 const_iterator end()
const {
return m_data.end(); }
31 const_iterator cbegin()
const {
return m_data.cbegin(); }
32 const_iterator cend()
const {
return m_data.cend(); }
34 reverse_iterator rbegin() {
return m_data.rbegin(); }
35 const_reverse_iterator rbegin()
const {
return m_data.rbegin(); }
37 reverse_iterator rend() {
return m_data.rend(); }
38 const_reverse_iterator rend()
const {
return m_data.rend(); }
40 const_reverse_iterator crbegin()
const {
return m_data.crbegin(); }
41 const_reverse_iterator crend()
const {
return m_data.crend(); }
65 m_data = other.m_data;
72 m_data = std::move(other._data);
80 m_data = other.m_data;
91 m_data = std::move(other._data);
113 return m_data.capacity();
122 return m_data.size();
130 return m_data.empty();
136 return m_data.max_size();
142 auto iter = std::find(m_data.begin(), m_data.end(), object);
143 if (iter != m_data.end())
144 return iter - m_data.begin();
153 const_iterator
find(T
object)
const 155 return std::find(m_data.begin(), m_data.end(), object);
158 iterator
find(T
object)
160 return std::find(m_data.begin(), m_data.end(), object);
164 T
at(
size_t index)
const 166 PE_ASSERT(index >= 0 && index <
size());
167 return m_data[index];
173 return m_data.front();
179 return m_data.back();
185 return(std::find(m_data.begin(), m_data.end(), object) != m_data.end());
191 size_t s = this->
size();
192 if (s != other.
size())
195 for (
size_t i = 0; i < s; i++)
197 if (this->
at(i) != other.
at(i))
214 PE_ASSERT(
object !=
nullptr);
215 m_data.push_back(
object);
222 for (
const auto &obj : other) {
223 m_data.push_back(obj);
236 PE_ASSERT(index >= 0 && index <=
size());
237 PE_ASSERT(
object !=
nullptr);
238 m_data.insert((std::begin(m_data) + index),
object);
249 PE_ASSERT(!m_data.empty());
250 auto last = m_data.back();
262 PE_ASSERT(
object !=
nullptr);
266 for (
auto iter = m_data.begin(); iter != m_data.end();)
268 if ((*iter) == object)
270 iter = m_data.erase(iter);
281 auto iter = std::find(m_data.begin(), m_data.end(), object);
282 if (iter != m_data.end())
297 PE_ASSERT(position >= m_data.begin() && position < m_data.end());
298 (*position)->Release();
299 size_t nIndex = position - m_data.begin();
301 *position = m_data.back();
304 return !m_data.empty() ? (m_data.begin()+nIndex) : m_data.end();
313 iterator
erase(iterator first, iterator last)
315 for (
auto iter = first; iter != last; ++iter)
320 return m_data.erase(first, last);
330 PE_ASSERT(!m_data.empty() && index >= 0 && index <
size());
331 auto it = std::next(begin(), index);
335 return !m_data.empty() ? (m_data.begin()+index) : m_data.end();
343 for (
auto it = std::begin(m_data); it != std::end(m_data); ++it) {
352 void swap(T object1, T object2)
357 PE_ASSERT(idx1 >= 0 && idx2 >= 0);
359 std::swap(m_data[idx1], m_data[idx2]);
363 void swap(
size_t index1,
size_t index2)
365 PE_ASSERT(index1 >= 0 && index1 <
size() && index2 >= 0 && index2 <
size());
367 std::swap(m_data[index1], m_data[index2]);
373 PE_ASSERT(index >= 0 && index <
size());
374 PE_ASSERT(
object !=
nullptr);
376 m_data[index]->Release();
377 m_data[index] = object;
384 std::reverse(std::begin(m_data), std::end(m_data));
390 m_data.shrink_to_fit();
398 for (
const auto &obj : m_data) {
403 base_class_type m_data;
bool contains(T object) const
Returns a Boolean value that indicates whether object is present in vector.
Definition: unordered_ref_array.h:183
const_iterator find(T object) const
Find the object in the vector.
Definition: unordered_ref_array.h:153
void shrink_to_fit()
Shrinks the vector so the memory footprint corresponds with the number of items.
Definition: unordered_ref_array.h:388
T at(size_t index) const
Returns the element at position 'index' in the vector.
Definition: unordered_ref_array.h:164
void pop_back()
Removes the last element in the vector, effectively reducing the container size by one...
Definition: unordered_ref_array.h:247
size_t capacity() const
Returns the size of the storage space currently allocated for the array, expressed in terms of elemen...
Definition: unordered_ref_array.h:111
T back() const
Returns the last element of the vector.
Definition: unordered_ref_array.h:177
bool empty() const
Returns whether the vector is empty (i.e.
Definition: unordered_ref_array.h:128
unordered_ref_array< T > & operator=(unordered_ref_array< T > &&other)
Move assignment operator.
Definition: unordered_ref_array.h:87
void swap(size_t index1, size_t index2)
Swap two elements with certain indexes.
Definition: unordered_ref_array.h:363
size_t max_size() const
Returns the maximum number of elements that the vector can hold.
Definition: unordered_ref_array.h:134
iterator erase(size_t index)
Removes from the vector with an index.
Definition: unordered_ref_array.h:328
void replace(size_t index, T object)
Replace object at index with another object.
Definition: unordered_ref_array.h:371
void insert(size_t index, T object)
Insert a certain object at a certain index.
Definition: unordered_ref_array.h:234
similar to unordered array except that it will automatically call addref/Release when obj is added/re...
Definition: unordered_ref_array.h:12
void swap(T object1, T object2)
Swap two elements.
Definition: unordered_ref_array.h:352
void reverse()
reverses the vector
Definition: unordered_ref_array.h:382
iterator erase(iterator position)
Removes from the vector with an iterator.
Definition: unordered_ref_array.h:295
void push_back(T object)
Adds a new element at the end of the vector, after its current last element.
Definition: unordered_ref_array.h:212
void push_back(const unordered_ref_array< T > &other)
Push all elements of an existing vector to the end of current vector.
Definition: unordered_ref_array.h:220
bool equals(const unordered_ref_array< T > &other)
Returns true if the two vectors are equal.
Definition: unordered_ref_array.h:189
T front() const
Returns the first element in the vector.
Definition: unordered_ref_array.h:171
void reserve(size_t n)
Request a change in capacity.
Definition: unordered_ref_array.h:101
size_t size() const
Returns the number of elements in the vector.
Definition: unordered_ref_array.h:120
unordered_ref_array< T > & operator=(const unordered_ref_array< T > &other)
Copy assignment operator.
Definition: unordered_ref_array.h:76
size_t getIndex(T object) const
Returns index of a certain object, return UINT_MAX if doesn't contain the object. ...
Definition: unordered_ref_array.h:140
void eraseObject(T object, bool removeAll=false)
Remove a certain object in Vector.
Definition: unordered_ref_array.h:260
iterator erase(iterator first, iterator last)
Removes from the vector with a range of elements ( [first, last) ).
Definition: unordered_ref_array.h:313
void addRefForAllObjects()
addrefs all the objects in the vector
Definition: unordered_ref_array.h:396
void clear()
Removes all elements from the vector (which are destroyed), leaving the container with a size of 0...
Definition: unordered_ref_array.h:341