PeriDyno
1.0.0
Loading...
Searching...
No Matches
D:
Peridyno
peridyno
src
Core
STL
Map.inl
Go to the documentation of this file.
1
#include "
Math/SimpleMath.h
"
2
#include <glm/glm.hpp>
3
4
#include "
STLMacro.h
"
5
6
namespace
dyno
7
{
8
template
<
typename
MKey,
typename
T>
9
DYN_FUNC
Map<MKey, T>::Map
()
10
{
11
}
12
13
template
<
typename
MKey,
typename
T>
14
DYN_FUNC
Pair<MKey, T>
*
Map<MKey, T>::find
(MKey key)
15
{
16
int
ind=
leftBound
(
Pair<MKey,T>
(key,
T
()),
m_pairs
,
m_size
);
17
return
(ind >=
m_size
||
m_pairs
[ind] !=
Pair<MKey, T>
(key,
T
())) ? nullptr : (
m_pairs
+ ind);
18
}
19
20
21
template
<
typename
MKey,
typename
T>
22
DYN_FUNC
Pair<MKey, T>
*
Map<MKey, T>::insert
(
Pair<MKey, T>
pair)
23
{
24
//return nullptr if the data buffer is full
25
if
(
m_size
>=
m_maxSize
)
return
nullptr
;
26
27
//return the index of the first element that is equel to or biger than val
28
int
t =
leftBound
(pair,
m_pairs
,
m_size
);
29
30
//if the key is equel, do not insert
31
if
(
m_pairs
[t] == pair)
32
return
m_pairs
+ t;
33
34
//insert val to t location
35
for
(
int
j =
m_size
; j > t; j--)
36
{
37
m_pairs
[j] =
m_pairs
[j - 1];
38
}
39
m_pairs
[t] = pair;
40
m_size
++;
41
42
return
m_pairs
+ t;
43
}
44
45
template
<
typename
MKey,
typename
T>
46
DYN_FUNC
void
Map<MKey, T>::clear
()
47
{
48
m_size
= 0;
49
}
50
51
template
<
typename
MKey,
typename
T>
52
DYN_FUNC
uint
Map<MKey, T>::size
()
53
{
54
return
m_size
;
55
}
56
57
template
<
typename
MKey,
typename
T>
58
DYN_FUNC
bool
Map<MKey, T>::empty
()
59
{
60
return
m_pairs
==
nullptr
;
61
}
62
}
63
STLMacro.h
SimpleMath.h
dyno::Map::find
DYN_FUNC iterator find(MKey key)
Definition
Map.inl:14
dyno::Map::m_maxSize
uint m_maxSize
Definition
Map.h:63
dyno::Map::clear
DYN_FUNC void clear()
Definition
Map.inl:46
dyno::Map::Map
DYN_FUNC Map()
Definition
Map.inl:9
dyno::Map::insert
DYN_FUNC iterator insert(Pair< MKey, T > pair)
Definition
Map.inl:22
dyno::Map::m_pairs
Pair< MKey, T > * m_pairs
Definition
Map.h:62
dyno::Map::empty
DYN_FUNC bool empty()
Definition
Map.inl:58
dyno::Map::m_size
uint m_size
Definition
Map.h:60
dyno::Map::size
DYN_FUNC uint size()
Definition
Map.inl:52
dyno::Pair
Definition
Pair.h:10
T
#define T(t)
dyno
This is an implementation of AdditiveCCD based on peridyno.
Definition
Array.h:25
dyno::leftBound
DYN_FUNC int leftBound(T target, T *startLoc, uint maxSize)
Find the left bound of a target with a binary search algorithm.
Definition
STLMacro.h:22
dyno::uint
unsigned int uint
Definition
VkProgram.h:14
Generated by
1.13.2