PeriDyno
1.0.0
Loading...
Searching...
No Matches
D:
Peridyno
peridyno
src
Core
STL
Stack.inl
Go to the documentation of this file.
1
#include "
Math/SimpleMath.h
"
2
#include <glm/glm.hpp>
3
4
namespace
dyno
5
{
6
template
<
typename
T>
7
DYN_FUNC
Stack<T>::Stack
()
8
{
9
}
10
11
template
<
typename
T>
12
DYN_FUNC
T
Stack<T>::top
()
13
{
14
return ::dyno::STLBuffer<T>::m_startLoc[
m_size
-1];
15
}
16
17
template
<
typename
T>
18
DYN_FUNC
void
Stack<T>::push
(
T
val)
19
{
20
//if the data buffer is full
21
//if (m_size >= m_maxSize)
22
//cout<<"Stack is full!"<<endl;
23
24
//if not full add to the end
25
::dyno::STLBuffer<T>::m_startLoc
[
m_size
] = val;
26
m_size
++;
27
}
28
29
template
<
typename
T>
30
DYN_FUNC
void
Stack<T>::pop
()
31
{
32
//if the data buffer is empty
33
//if (m_size == 0 )
34
//cout << "Stack is empty!" << endl;
35
36
//else return the data at the top
37
m_size
=
m_size
> 0 ?
m_size
- 1 : 0;
38
}
39
40
template
<
typename
T>
41
DYN_FUNC
void
Stack<T>::clear
()
42
{
43
m_size
= 0;
44
}
45
46
template
<
typename
T>
47
DYN_FUNC
uint
Stack<T>::size
()
48
{
49
return
m_size
;
50
}
51
52
template
<
typename
T>
53
DYN_FUNC
uint
Stack<T>::count
(
T
val)
54
{
55
uint
ind = 0;
56
uint
num = 0;
57
while
(ind <
m_size
)
58
{
59
if
(
::dyno::STLBuffer<T>::m_startLoc
[ind] == val)
60
num++;
61
ind++;
62
}
63
64
return
num;
65
}
66
67
template
<
typename
T>
68
DYN_FUNC
bool
Stack<T>::empty
()
69
{
70
return
m_size
== 0;
71
}
72
}
73
SimpleMath.h
dyno::STLBuffer::m_startLoc
T * m_startLoc
Definition
STLBuffer.h:38
dyno::Stack::pop
DYN_FUNC void pop()
Definition
Stack.inl:30
dyno::Stack::clear
DYN_FUNC void clear()
Definition
Stack.inl:41
dyno::Stack::push
DYN_FUNC void push(T val)
Definition
Stack.inl:18
dyno::Stack::Stack
DYN_FUNC Stack()
Definition
Stack.inl:7
dyno::Stack::top
DYN_FUNC T top()
Definition
Stack.inl:12
dyno::Stack::size
DYN_FUNC uint size()
Definition
Stack.inl:47
dyno::Stack::count
DYN_FUNC uint count(T val)
Definition
Stack.inl:53
dyno::Stack::empty
DYN_FUNC bool empty()
Definition
Stack.inl:68
dyno::Stack::m_size
uint m_size
Definition
Stack.h:45
T
#define T(t)
dyno
This is an implementation of AdditiveCCD based on peridyno.
Definition
Array.h:25
dyno::uint
unsigned int uint
Definition
VkProgram.h:14
Generated by
1.13.2