view algs4-c++/src/Queue.cpp @ 16:eb159ea69f33

Updated Queue to have the implementation in the header file. I forgot that templates need the implementation visible to the copmiler in the place where the code is generated - it can't be properly generated if it's in a separate file.
author Eris Caffee <discordia@eldalin.com>
date Fri, 19 Jun 2015 18:17:46 -0500
parents b02533162b6e
children 028689700a47
line source
1 // g++ -std=c++11 Queue.cpp
4 #include <iostream>
6 #include "Queue.hpp"
8 int main ( int argc, char **argv ) {
10 Queue<long> queue;
12 long i;
13 while ( ! std::cin.eof() ) {
14 std::cin >> i;
15 if ( std::cin.good() )
16 if ( i >= 0 )
17 queue.enqueue(i);
18 else
19 queue.dequeue();
20 }
22 std::cout << "Queue has " << queue.size() << " entries." << std::endl;
24 for ( auto iter = queue.begin(); iter != queue.end(); ++iter ) {
25 std::cout << *iter << std::endl;
26 }
28 std::cout << "Dequeuing entries..." << std::endl;
30 while ( ! queue.is_empty() ) {
31 i = queue.dequeue();
32 std::cout << i << std::endl;
33 }
35 std::cout << "Queue has " << queue.size() << " entries." << std::endl;
37 }