-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueue.h
62 lines (41 loc) · 943 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef QUEUE_
#define QUEUE_ 1
#include <iostream>
#include <initializer_list>
#include <string>
class queue
{
struct node
{
std::string value;
node *next;
node(const std::string &value, node *next = nullptr) : value(value),
next(next)
{
}
};
size_t queue_size;
node *front;
node *back;
public:
queue();
queue(const queue &q);
const queue &operator=(const queue &q);
~queue();
queue(std::initializer_list<std::string> init);
void push(const std::string &s);
void pop();
void clear();
void reset(size_t s);
const std::string &peek() const;
size_t size() const;
bool empty() const;
void print(std::ostream &out) const;
friend int main(int argc, char *argv[]);
};
inline std::ostream &operator<<(std::ostream &out, const queue &q)
{
q.print(out);
return out;
}
#endif