Mercurial > Algorithms__Sedgewick
view algs4-c++/src/RandomBag.cpp @ 27:80ca1973e3bd
Fleshed out Queue::generic_iterator a bit more to make it a more or less complete example of implmenting an iterator.
author | Eris Caffee <discordia@eldalin.com> |
---|---|
date | Tue, 23 Jun 2015 17:14:09 -0500 |
parents | 63df3e6590e2 |
children |
line source
1 // g++ -std=c++11 RandomBag.cpp
3 #include "RandomBag.hpp"
5 #include <iostream>
7 int main ( int argc, char **argv ) {
9 RandomBag<long> random_bag;
11 long i;
12 while ( ! std::cin.eof() ) {
13 std::cin >> i;
14 if ( std::cin.good() )
15 random_bag.add(i);
16 }
18 std::cout << "RandomBag has " << random_bag.size() << " entries." << std::endl;
20 for ( auto iter = random_bag.begin(); iter != random_bag.end(); ++iter ) {
21 std::cout << *iter << std::endl;
22 }
25 }