blob: f0e69f84a73d6f6292a43113d1e11ac544fcf45d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*
* Stack.cpp
*
* Created on: 15 Apr 2013
* Author: s0965328
*/
#include <cstddef>
#include <math.h>
#include <cassert>
#include "Stack.h"
namespace AutoDiff {
Stack* Stack::vals = NULL;
Stack* Stack::diff = NULL;
Stack::Stack()
{
}
Stack::~Stack() {
this->clear();
}
double Stack::pop_back()
{
assert(this->lifo.size()!=0);
double v = this->lifo.top();
lifo.pop();
return v;
}
void Stack::push_back(double& v)
{
assert(!isnan(v));
this->lifo.push(v);
}
double& Stack::peek()
{
return this->lifo.top();
}
unsigned int Stack::size()
{
return this->lifo.size();
}
void Stack::clear()
{
while(!this->lifo.empty())
{
this->lifo.pop();
}
}
}
|