BFLibCPP
0.1
CPP Library
Loading...
Searching...
No Matches
stack.hpp
Go to the documentation of this file.
1
6
#ifndef STACK_HPP
7
#define STACK_HPP
8
9
#include "
access.hpp
"
10
#include "
list.hpp
"
11
12
namespace
BF
{
13
22
template
<
typename
T,
typename
S =
int
>
23
class
Stack
:
protected
List
<T, S> {
24
public
:
25
Stack
() :
List
<T,S>() {
26
27
}
28
29
~Stack
() {
30
31
}
32
33
int
push
(T
object
) {
34
return
this->
add
(
object
);
35
}
36
37
int
pop
() {
38
return
this->
deleteNode
(this->
last
());
39
}
40
41
T
top
() {
42
typename
List<T,S>::Node
* n = this->
last
();
43
if
(n)
return
n->
object
();
44
return
0;
45
}
46
47
S
size
() {
return
this->
count
(); }
48
49
bool
empty
() {
return
this->
count
() == 0; };
50
};
51
52
}
// namespace BF
53
54
#endif
// STACK_HPP
55
access.hpp
BF::List::Node
Definition
list.hpp:47
BF::List::Node::object
L object() const
Definition
list.hpp:58
BF::List
Definition
list.hpp:41
BF::List< T, int >::count
int count() const
Definition
list.hpp:104
BF::List< T, int >::last
Node * last() const
Definition
list.hpp:229
BF::List< T, int >::add
int add(T obj)
Definition
list.hpp:107
BF::List< T, int >::deleteNode
int deleteNode(Node *node)
Definition
list.hpp:288
BF::Stack
Definition
stack.hpp:23
BF::Stack::empty
bool empty()
Definition
stack.hpp:49
BF::Stack::Stack
Stack()
Definition
stack.hpp:25
BF::Stack::~Stack
~Stack()
Definition
stack.hpp:29
BF::Stack::size
S size()
Definition
stack.hpp:47
BF::Stack::top
T top()
Definition
stack.hpp:41
BF::Stack::push
int push(T object)
Definition
stack.hpp:33
BF::Stack::pop
int pop()
Definition
stack.hpp:37
list.hpp
BF
Definition
array.hpp:18
libs
bflibcpp
src
stack.hpp
Generated by
1.11.0