RavEngine
Loading...
Searching...
No Matches
unordered_vector.hpp
1#pragma once
2#include <vector>
3#include <algorithm>
4
5namespace RavEngine {
6
13template<typename T, typename vec = std::vector<T>>
15 vec underlying;
16public:
17 typedef typename decltype(underlying)::iterator iterator_type;
18 typedef typename decltype(underlying)::const_iterator const_iterator_type;
19 typedef typename decltype(underlying)::size_type index_type;
20 typedef typename decltype(underlying)::size_type size_type;
21 using value_type = T;
22
27 inline const_iterator_type erase(iterator_type it){
28 *it = std::move(underlying.back());
29 underlying.pop_back();
30 return it;
31 }
32
36 inline auto& get_underlying() {
37 return underlying;
38 }
39
44 inline const_iterator_type erase(const T& value){
45 auto it = std::find(underlying.begin(),underlying.end(),value);
46 underlying.erase(it);
47 return it;
48 }
49
56 inline T& insert(const T& value){
57 underlying.push_back(value);
58 return underlying.back();
59 }
60
67 template<typename ... A>
68 inline T& emplace(A&& ... args){
69 underlying.emplace_back(std::forward<A>(args)...);
70 return underlying.back();
71 }
72
73 inline T& operator[](index_type idx){
74 return underlying[idx];
75 }
76
77 const inline T& operator[](index_type idx) const{
78 return underlying[idx];
79 }
80
81 inline T& at(index_type idx){
82 return underlying.at(idx);
83 }
84
85 const inline T& at(index_type idx) const{
86 return underlying.at(idx);
87 }
88
89 inline const_iterator_type begin() const{
90 return underlying.begin();
91 }
92
93 inline const_iterator_type end() const{
94 return underlying.end();
95 }
96
97 inline iterator_type end(){
98 return underlying.end();
99 }
100
101 inline iterator_type begin(){
102 return underlying.begin();
103 }
104
105 inline size_type size() const{
106 return underlying.size();
107 }
108
109 inline void reserve(size_t num){
110 underlying.reserve(num);
111 }
112
113 inline void resize(size_t num){
114 underlying.resize(num);
115 }
116
117 inline bool empty() const{
118 return underlying.empty();
119 }
120
121 inline void clear(){
122 underlying.clear();
123 }
124
125 inline auto data() const{
126 return underlying.data();
127 }
128};
129
130}
Definition unordered_vector.hpp:14
const_iterator_type erase(const T &value)
Definition unordered_vector.hpp:44
const_iterator_type erase(iterator_type it)
Definition unordered_vector.hpp:27
auto & get_underlying()
Definition unordered_vector.hpp:36
T & emplace(A &&... args)
Definition unordered_vector.hpp:68
T & insert(const T &value)
Definition unordered_vector.hpp:56
Definition Animation.hpp:6