1 #include "DataStructures.hpp"
2 #include "GenericStorageContainerTemplateImpl.hpp"
9 main (int argc, char **argv, char **env)
11 cout << "Generic Storage Template (with Iterator) Test" << endl
12 << "Copyright 2014 TJ <hacker@iam.tj>" << endl
13 << "Licensed on terms of the GNU General Public License version 3.0" << endl;
15 GSCTI<int, DataStructure_ArrayDynamic> my_collection_of_ints;
23 cout << endl << "Menu" << endl
24 << "1. Add node" << endl
25 << "2. Remove node" << endl
26 << "3. List nodes using forward Iterator" << endl
27 << "4. List nodes using reverse Interator" << endl
37 test = new int(76543);
38 if (!my_collection_of_ints.append(*test))
39 cerr << "Error: insert failed" << endl;
41 case 2: // Remove node
42 if (!my_collection_of_ints.remove())
43 cerr << "Error: remove failed" << endl;
45 case 3: // List using forward Iterator
46 cout << "size = " << my_collection_of_ints.get_size() << endl;
48 /* the traditional style of iterator loop
49 for (GSCTI<int, DataStructure_ArrayDynamic>::_iterator end = my_collection_of_ints.end(),
50 i = my_collection_of_ints.begin();
54 cout << "Data = " << *i << endl;
58 /* the modern range-based for loop
59 * see http://en.cppreference.com/w/cpp/language/range-for
61 for (auto i : my_collection_of_ints) // XXX: C++11 'range for' automagically uses the iterator
63 cout << "Data = " << i << endl;
67 case 4: // List using reverse Iterator
71 } while (menu_choice > 0);