typename fix
[prop.git] / tests / qa8.cc
blobb8ba35a5613d44b359b5675d442744e62aeb422f
1 // Test some container stuff
3 #include <stdio.h>
4 #include <assert.h>
5 #include <AD/contain/array.h> // Arrays
6 #include <AD/contain/arraycol.h> // Array collections
7 #include <AD/contain/charset.h> // Set of ASCII characters
8 #include <AD/contain/dchbag.h> // Multiset
9 #include <AD/contain/dchset.h> // Set
10 #include <AD/contain/dchmap.h> // Associative table
11 #include <AD/contain/fixstack.h> // Fixed sized stack
12 #include <AD/contain/fixqueue.h> // Fixed sized queue
13 #include <AD/contain/intset.h> // Set of integers
14 #include <AD/contain/linklist.h> // Linked lists
15 #include <AD/contain/priqueue.h> // Priority queue
16 #include <AD/contain/queue.h> // Queues
17 #include <AD/contain/seq.h> // Sequences
18 #include <AD/contain/stack.h> // Stacks
19 #include <AD/contain/unionfnd.h> // Union find data structure
20 #include <AD/contain/vararray.h> // Variable sized array
21 #include <AD/contain/varqueue.h> // Variable sized queue
22 #include <AD/contain/varstack.h> // Variable sized stack
24 int main(int argc, char * argv[])
25 { CharSet C;
26 DCHBag<char *> bag;
27 DCHSet<char *> set;
28 DCHMap<char *,char *> M;
29 FixStack<int,100> S;
30 VarStack<char *> s1, s2;
31 Seq<char> text;
32 PriQueue<int, Array<int> > pq(256);
33 LinkedList<char *> list;
34 VarArray<char *> array(0,3);
36 C.clear();
37 C += 'a';
38 C += 'b';
39 assert(C.size() == 2);
41 S.push(1); S.push(2); S.push(3);
42 S.pop();
43 assert(S.size() == 2);
45 s1.push("allen"); s1.push("leung");
46 s2 = s1;
47 s2.pop();
48 assert(s1.size() == 2);
49 assert(s2.size() == 1);
51 M[ "John" ] = "Gleese";
52 M[ "Neal" ] = "Skyer";
53 M[ "Freud" ] = "Fraud";
54 M[ "Judy" ] = "Davis";
55 M[ "Robert" ] = "DeNiro";
56 M[ "Lawrence" ] = "Oliver";
57 M[ "Woody" ] = "Allen";
58 M[ "Harrison" ] = "Ford";
59 M[ "Mickey" ] = "Rourke";
60 M[ "Humphry" ] = "Bogart";
62 for (Ix i = M.first(); i; i = M.next(i))
63 printf("First = %s, last = %s\n", M.key(i), M.value(i));
65 assert(M.size() == 10);
67 ((list += "Bell") += "Cleary") += "Witten";
69 assert(list.length() == 3);
71 for (LinkedListIter<char *> j = list; j; j++)
72 printf("Name = %s\n", j());
74 array[0] = "Eva";
75 array[1] = "Luna";
76 array[2] = "Isaac";
77 array[3] = "Albeniz";
78 array[4] = "Villa";
79 array[5] = "Lobos";
80 array[-2] = "Manuel";
81 array[-1] = "Ponce";
83 int n;
85 for (n = -2; n <= 5; n++)
86 printf("array[%d] = %s\n", n, array[n]);
88 VarQueue<int> VQ;
89 for (n = 0; n < 20; n++)
90 VQ.insert_tail(n);
91 while (! VQ.is_empty()) {
92 printf("%d ",VQ.remove_head());
94 printf("\n");
96 ArrayCollection< int, Array<int> > ac;
98 printf("OK\n");
99 return 0;