-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathstack.h
More file actions
34 lines (25 loc) · 721 Bytes
/
stack.h
File metadata and controls
34 lines (25 loc) · 721 Bytes
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
#ifndef STRUCTURES_STACK_H
#define STRUCTURES_STACK_H
#include <cstdint>
#include <array_list.h>
#include <traits.h>
namespace structures {
template <typename T, typename Container>
class StackWrapper {
public:
void push(const T& data) { return cont.push_back(data); }
T pop() { return cont.pop_back(); }
T& top() { return cont.back(); }
const T& top() const { return cont.back(); }
void clear() { return cont.clear(); }
std::size_t size() const { return cont.size(); }
private:
Container cont;
};
template <typename T>
class Stack : public StackWrapper<T, ArrayList<T>> {};
} // namespace structures
/* name trait */
template <>
const std::string traits::type<structures::Stack>::name = "Stack";
#endif