--- UnitTest.cpp 2004/05/14 18:26:01 8 +++ UnitTest.cpp 2004/05/14 18:54:07 9 @@ -10,6 +10,17 @@ using namespace std; +template +bool contains(const Type& value, DoublyLinkedList& list) +{ + for (Iterator itor(list.iterator()); !itor.end(); itor++) + { + if (*itor == value) return true; + } + + return false; +} + int main(int argc, char* argv[]) { cout.setf(ios_base::boolalpha); @@ -41,5 +52,21 @@ int main(int argc, char* argv[]) cout << *itor << '\n'; } + cout << "contains(3, list) = " << contains(3, list) << '\n' + << "contains(4, list) = " << contains(4, list) << '\n'; + + DoublyLinkedList words; + + words.addFront("Douglas"); + words.addBack("Allen"); + words.addFront("Edward"); + words.addBack("attack"); + words.addFront("Thrift"); + + for (Iterator itor(words.iterator()); !itor.end(); itor++) + { + if (itor->find_first_of("aAeEiIoOuU") == 0) cout << *itor << '\n'; + } + return 0; }