From f4c20290509d7ed3a8fd5304577e7a4cc0b9d974 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 3 Apr 2007 03:49:53 +0000 Subject: Ok, no code is left in src, it's all in src/old. We'll gradually move code back into src as it's fixed and re-org'd. This includes tests, which, I may write a unit test system into libbu++ just to make my life easier. --- src/old/tests/ordhash.cpp | 48 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/old/tests/ordhash.cpp (limited to 'src/old/tests/ordhash.cpp') diff --git a/src/old/tests/ordhash.cpp b/src/old/tests/ordhash.cpp new file mode 100644 index 0000000..f1d96ec --- /dev/null +++ b/src/old/tests/ordhash.cpp @@ -0,0 +1,48 @@ +#include "ordhash.h" +#include + +typedef struct eldef +{ + eldef( int a, int b, const std::string &c ) : + id( a ), nSequence( b ), sName( c ) {} + int id; + int nSequence; + std::string sName; +} eldef; + +struct seqcmp +{ + bool operator()( eldef **a, eldef **b ) + { + return (*a)->nSequence < (*b)->nSequence; + } +}; + +struct namcmp +{ + bool operator()( eldef **a, eldef **b ) + { + return (*a)->sName < (*b)->sName; + } +}; + +typedef OrdHash AHash; +//typedef OrdHash AHash; + +int main() +{ + AHash hsh; + hsh[1] = eldef( 0, 43, "Bob"); + hsh[4] = eldef( 1, 443, "Abby"); + hsh[2] = eldef( 2, 1, "Name"); + hsh[5] = eldef( 3, 0, "Catagory"); + hsh[32] = eldef( 4, 12, "Epilogue"); + + for( AHash::iterator i = hsh.begin(); i != hsh.end(); i++ ) + { + eldef e = (*i).second; + printf("%d, %d, %s\n", e.id, e.nSequence, e.sName.c_str() ); + } + +} + -- cgit v1.2.3