Tools.h++ Class Reference

Table Of Contents
Persistence
Isomorphic
Example
In this example, a double-ended queue of ints is exercised.
// tpdeque.cpp
#include <rw/tpdeque.h>
#include <iostream.h>
/*
* This program partitions integers into even and odd numbers
*/
int main(){
RWTPtrDeque<int> numbers;
int n;
cout << "Input an assortment of integers (EOF to end):"
<< endl;
while (cin >> n) {
if (n % 2 == 0)
numbers.pushFront(new int(n));
else
numbers.pushBack(new int(n));
}
while (numbers.entries()) {
cout << *numbers.first() << endl;
delete numbers.popFront();
}
return 0;
}
Program Input:
1 2 3 4 5
<eof>
Program Output:
4
2
1
3
5