-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathqueue.h
36 lines (27 loc) · 829 Bytes
/
queue.h
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
#ifndef STRUCTURES_QUEUE_H
#define STRUCTURES_QUEUE_H
#include <cstdint>
#include <doubly_circular_list.h>
#include <traits.h>
namespace structures {
template <typename T, typename Container>
class QueueWrapper {
public:
void push(const T& data) { return cont.push_back(data); }
T pop() { return cont.pop_front(); }
T& front() { return cont.front(); }
const T& front() const { return cont.front(); }
T& back() { return cont.back(); }
const T& back() const { return cont.back(); }
void clear() { return cont.clear(); }
std::size_t size() const { return cont.size(); }
private:
Container cont;
};
template <typename T>
class Queue : public QueueWrapper<T, DoublyCircularList<T>> {};
} // namespace structures
/* name trait */
template <>
const std::string traits::type<structures::Queue>::name = "Queue";
#endif