1 //////////////////////////////////////////////////////////////////////////////
4 // ADLib, Prop and their related set of tools and documentation are in the
5 // public domain. The author(s) of this software reserve no copyrights on
6 // the source code and any code generated using the tools. You are encouraged
7 // to use ADLib and Prop to develop software, in both academic and commercial
8 // settings, and are free to incorporate any part of ADLib and Prop into
11 // Although you are under no obligation to do so, we strongly recommend that
12 // you give away all software developed using our tools.
14 // We also ask that credit be given to us when ADLib and/or Prop are used in
15 // your programs, and that this notice be preserved intact in all the source
18 // This software is still under development and we welcome any suggestions
19 // and help from the users.
23 //////////////////////////////////////////////////////////////////////////////
27 #include <AD/contain/array.h> // Arrays
28 #include <AD/contain/arraycol.h> // Array collections
29 #include <AD/contain/charset.h> // Set of ASCII characters
30 #include <AD/contain/dchbag.h> // Multiset
31 #include <AD/contain/dchset.h> // Set
32 #include <AD/contain/dchmap.h> // Associative table
33 #include <AD/contain/fixstack.h> // Fixed sized stack
34 #include <AD/contain/fixqueue.h> // Fixed sized queue
35 #include <AD/contain/intset.h> // Set of integers
36 #include <AD/contain/linklist.h> // Linked lists
37 #include <AD/contain/priqueue.h> // Priority queue
38 #include <AD/contain/queue.h> // Queues
39 #include <AD/contain/seq.h> // Sequences
40 #include <AD/contain/stack.h> // Stacks
41 #include <AD/contain/unionfnd.h> // Union find data structure
42 #include <AD/contain/vararray.h> // Variable sized array
43 #include <AD/contain/varqueue.h> // Variable sized queue
44 #include <AD/contain/varstack.h> // Variable sized stack
46 int main(int argc
, char * argv
[])
50 DCHMap
<char *,char *> M
;
52 VarStack
<char *> s1
, s2
;
54 PriQueue
<int, Array
<int> > pq(256);
55 LinkedList
<char *> list
;
56 VarArray
<char *> array(0,3);
61 assert(C
.size() == 2);
63 S
.push(1); S
.push(2); S
.push(3);
65 assert(S
.size() == 2);
67 s1
.push("allen"); s1
.push("leung");
70 assert(s1
.size() == 2);
71 assert(s2
.size() == 1);
73 M
[ "John" ] = "Gleese";
74 M
[ "Neal" ] = "Skyer";
75 M
[ "Freud" ] = "Fraud";
76 M
[ "Judy" ] = "Davis";
77 M
[ "Robert" ] = "DeNiro";
78 M
[ "Lawrence" ] = "Oliver";
79 M
[ "Woody" ] = "Allen";
80 M
[ "Harrison" ] = "Ford";
81 M
[ "Mickey" ] = "Rourke";
82 M
[ "Humphry" ] = "Bogart";
84 for (Ix i
= M
.first(); i
; i
= M
.next(i
))
85 printf("First = %s, last = %s\n", M
.key(i
), M
.value(i
));
87 assert(M
.size() == 10);
89 ((list
+= "Bell") += "Cleary") += "Witten";
91 assert(list
.length() == 3);
93 for (LinkedListIter
<char *> j
= list
; j
; j
++)
94 printf("Name = %s\n", j());
102 array
[-2] = "Manuel";
105 for (int n
= -2; n
<= 5; n
++)
106 printf("array[%d] = %s\n", n
, array
[n
]);
109 for (n
= 0; n
< 20; n
++)
111 while (! VQ
.isEmpty()) {
112 printf("%d ",VQ
.removeHead());
116 ArrayCollection
< int, Array
<int> > ac
;