1 // Test some container stuff
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
[])
28 DCHMap
<char *,char *> M
;
30 VarStack
<char *> s1
, s2
;
32 PriQueue
<int, Array
<int> > pq(256);
33 LinkedList
<char *> list
;
34 VarArray
<char *> array(0,3);
39 assert(C
.size() == 2);
41 S
.push(1); S
.push(2); S
.push(3);
43 assert(S
.size() == 2);
45 s1
.push("allen"); s1
.push("leung");
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());
85 for (n
= -2; n
<= 5; n
++)
86 printf("array[%d] = %s\n", n
, array
[n
]);
89 for (n
= 0; n
< 20; n
++)
91 while (! VQ
.is_empty()) {
92 printf("%d ",VQ
.remove_head());
96 ArrayCollection
< int, Array
<int> > ac
;