Ne.app NeANT
The Ne.app NeANT User module of the NeANT distribution.
queue.cpp
Go to the documentation of this file.
1
29#include <deque> // for deque
30#include <iostream> // for cout, endl
31#include <list> // for list
32#include <queue> // for queue
33#include <string> // for string
34
35#include <examples.h>
36
37int main ()
38{
39 typedef std::queue<int, std::list<int, std::allocator<int> > > IQueue;
40
41 // Make a queue using a deque container.
42 IQueue q;
43
44 // Push a couple of values on and retrieve them.
45 q.push (1);
46 q.push (2);
47
48 std::cout << q.front () << std::endl;
49 std::cout << q.back () << std::endl;
50
51 typedef std::queue<std::string, std::deque<std::string,
52 std::allocator<std::string> > > SQueue;
53
54 // Make a queue of strings using a deque container.
55 SQueue qs;
56
57 // Push on a few strings then pop them back off.
58 for (std::string::size_type i = 0U; i != 10U; i++) {
59 qs.push (std::string (i + 1, 'a'));
60 std::cout << qs.front () << std::endl;
61 }
62
63 for (std::string::size_type j = 0U; j != 10U; j++) {
64 std::cout << qs.front () << std::endl;
65 qs.pop ();
66 }
67
68 // Return 0 if both containers are empty, a non-zero value otherwise.
69 return !(2 == q.size () && qs.empty ());
70}
#define i
Definition 17.names.cpp:126
#define q
Definition 17.names.cpp:133
#define j
Definition 17.names.cpp:127
#define U
Definition 17.names.cpp:164
int main()
Definition queue.cpp:37