-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.h
52 lines (35 loc) · 1.18 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// File: queue.h
// Author: Viktor Slavkovic
// Date: May 2016
#ifndef _STL_QUEUE_H_
#define _STL_QUEUE_H_
#include "list.h"
// It seems that BCC doesn't support this:
// template<class T, class Container = list<T> >
template <class T>
class queue {
public:
typedef list<T> Container;
typedef T value_type;
typedef Container::size_type size_type;
typedef Container::iterator iterator;
queue() : container_() {}
queue(const queue& cp) : container_(cp.container_) {}
int empty() const { return container_.empty(); }
size_type size() const { return container_.size(); }
value_type& front() { return container_.front(); };
const value_type& front() const { return container_.front(); }
void push(const value_type& val) { container_.push_back(val); }
void pop() { container_.pop_front(); }
int operator==(const queue& rhs) const {
return container_ == rhs.container_;
}
int operator!=(const queue& rhs) const {
return container_ != rhs.container_;
}
iterator begin() { return container_.begin(); }
iterator end() { return container_.end(); }
private:
Container container_;
};
#endif // _STL_QUEUE_H_