aboutsummaryrefslogtreecommitdiff
path: root/src/tests/ordhash.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/tests/ordhash.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/tests/ordhash.cpp b/src/tests/ordhash.cpp
new file mode 100644
index 0000000..f1d96ec
--- /dev/null
+++ b/src/tests/ordhash.cpp
@@ -0,0 +1,48 @@
1#include "ordhash.h"
2#include <string>
3
4typedef struct eldef
5{
6 eldef( int a, int b, const std::string &c ) :
7 id( a ), nSequence( b ), sName( c ) {}
8 int id;
9 int nSequence;
10 std::string sName;
11} eldef;
12
13struct seqcmp
14{
15 bool operator()( eldef **a, eldef **b )
16 {
17 return (*a)->nSequence < (*b)->nSequence;
18 }
19};
20
21struct namcmp
22{
23 bool operator()( eldef **a, eldef **b )
24 {
25 return (*a)->sName < (*b)->sName;
26 }
27};
28
29typedef OrdHash<int, eldef, seqcmp> AHash;
30//typedef OrdHash<int, eldef, namcmp> AHash;
31
32int main()
33{
34 AHash hsh;
35 hsh[1] = eldef( 0, 43, "Bob");
36 hsh[4] = eldef( 1, 443, "Abby");
37 hsh[2] = eldef( 2, 1, "Name");
38 hsh[5] = eldef( 3, 0, "Catagory");
39 hsh[32] = eldef( 4, 12, "Epilogue");
40
41 for( AHash::iterator i = hsh.begin(); i != hsh.end(); i++ )
42 {
43 eldef e = (*i).second;
44 printf("%d, %d, %s\n", e.id, e.nSequence, e.sName.c_str() );
45 }
46
47}
48