ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/ccscs20/UnitTest.cpp
(Generate patch)

Comparing UnitTest.cpp (file contents):
Revision 6 by Douglas Thrift, 2004-05-13T23:17:43-07:00 vs.
Revision 9 by Douglas Thrift, 2004-05-14T11:54:07-07:00

# Line 10 | Line 10
10  
11   using namespace std;
12  
13 + template<typename Type>
14 + bool contains(const Type& value, DoublyLinkedList<Type>& list)
15 + {
16 +        for (Iterator<Type> itor(list.iterator()); !itor.end(); itor++)
17 +        {
18 +                if (*itor == value) return true;
19 +        }
20 +
21 +        return false;
22 + }
23 +
24   int main(int argc, char* argv[])
25   {
26          cout.setf(ios_base::boolalpha);
# Line 21 | Line 32 | int main(int argc, char* argv[])
32          list.addFront(4);
33          list.addBack(5);
34  
35 +        // 4 1 2 5
36 +
37          cout << "list.contains(1) = " << list.contains(1) << '\n'
38                  << "list.contains(2) = " << list.contains(2) << '\n'
39                  << "list.contains(3) = " << list.contains(3) << '\n'
# Line 29 | Line 42 | int main(int argc, char* argv[])
42  
43          list.removeFirst(2);
44  
45 <        cout << "list.contains(2) = " << list.contains(2) << '\n';
45 >        // 4 1 5
46 >
47 >        cout << "list.contains(2) = " << list.contains(2) << '\n'
48 >                << "list.contains(5) = " << list.contains(5) << '\n';
49 >
50 >        for (Iterator<int> itor(list.iterator()); !itor.end(); itor++)
51 >        {
52 >                cout << *itor << '\n';
53 >        }
54 >
55 >        cout << "contains(3, list) = " << contains(3, list) << '\n'
56 >                << "contains(4, list) = " << contains(4, list) << '\n';
57 >
58 >        DoublyLinkedList<string> words;
59 >
60 >        words.addFront("Douglas");
61 >        words.addBack("Allen");
62 >        words.addFront("Edward");
63 >        words.addBack("attack");
64 >        words.addFront("Thrift");
65 >
66 >        for (Iterator<string> itor(words.iterator()); !itor.end(); itor++)
67 >        {
68 >                if (itor->find_first_of("aAeEiIoOuU") == 0) cout << *itor << '\n';
69 >        }
70  
71          return 0;
72   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines