Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Friends
Macros
Pages
include
paal
data_structures
stack.hpp
Go to the documentation of this file.
1
8
#ifndef PAAL_STACK_HPP
9
#define PAAL_STACK_HPP
10
11
#include <vector>
12
13
namespace
paal {
14
namespace
data_structures {
15
17
template
<
class
T>
class
stack
{
18
std::vector<T> m_v;
19
std::size_t m_size;
20
public
:
22
stack
() : m_v(std::vector<T>()), m_size(0) {}
24
void
push
() {
25
if
(++m_size > m_v.size()) m_v.resize(m_size);
26
}
28
void
pop
() { --m_size; }
30
const
T &
top
()
const
{
return
m_v[m_size - 1]; }
32
T &
top
() {
return
m_v[m_size - 1]; }
34
bool
empty
()
const
{
return
m_size == 0; }
36
std::size_t
size
()
const
{
return
m_size; }
37
};
38
39
}
// !data_structures
40
}
// !paal
41
42
#endif
/* PAAL_STACK_HPP */
paal::data_structures::stack::size
std::size_t size() const
size
Definition:
stack.hpp:36
paal::data_structures::stack::top
T & top()
top
Definition:
stack.hpp:32
paal::data_structures::stack::empty
bool empty() const
empty
Definition:
stack.hpp:34
paal::data_structures::stack
Stack.
Definition:
stack.hpp:17
paal::data_structures::stack::top
const T & top() const
top
Definition:
stack.hpp:30
paal::data_structures::stack::push
void push()
push
Definition:
stack.hpp:24
paal::data_structures::stack::stack
stack()
constructor
Definition:
stack.hpp:22
paal::data_structures::stack::pop
void pop()
pop doesn't call destructor
Definition:
stack.hpp:28
Generated on Tue Jan 31 2017 00:30:50 by
1.8.5