Gorgon Game Engine
Vector.h
Go to the documentation of this file.
1
#pragma once
2
3
#include <utility>
4
5
namespace
Gorgon
{
namespace
Containers {
6
9
template
<
class
T_,
class
V_>
10
void
PushBackUnique
(V_ &vector, T_ &&val) {
11
for
(
const
auto
&e : vector) {
12
if
(e == val)
return
;
13
}
14
15
vector.push_back(std::forward<T_>(val));
16
}
17
21
template
<
class
T_,
class
V_,
class
P_>
22
void
PushBackUnique
(V_ &vector,
const
T_ &val, P_ pred) {
23
for
(
const
auto
&e : vector) {
24
if
(pred(e, val))
return
;
25
}
26
27
vector.push_back(val);
28
}
29
33
template
<
class
T_,
class
V_>
34
void
PushBackOrUpdate
(V_ &vector, T_ &&val) {
35
for
(
auto
&e : vector) {
36
if
(e == val) e = std::forward<T_>(val);
37
}
38
39
vector.push_back(std::forward<T_>(val));
40
}
41
45
template
<
class
T_,
class
V_,
class
P_>
46
void
PushBackOrUpdate
(V_ &vector,
const
T_ &val, P_ pred) {
47
for
(
auto
&e : vector) {
48
if
(pred(e, val)) e = std::forward<T_>(val);
49
}
50
51
vector.push_back(val);
52
}
53
54
}}
Gorgon
Root namespace for Gorgon Game Engine.
Definition:
Any.h:19
Gorgon::Containers::PushBackUnique
void PushBackUnique(V_ &vector, T_ &&val)
This function push_backs an item to the given vector if the item does not exists in the vector.
Definition:
Vector.h:10
Gorgon::Containers::PushBackOrUpdate
void PushBackOrUpdate(V_ &vector, T_ &&val)
This function push_backs an item to the given vector if the item does not exists in the vector,...
Definition:
Vector.h:34
Gorgon
Containers
Vector.h
Generated on Sun Nov 15 2020 14:36:03 for Gorgon Game Engine by
1.8.20