From 6f6bb9f9309a6d5e471579ec565d56e4d083dafb Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 21 Nov 2006 16:01:57 +0000 Subject: Added erase functionality, and specializations for using ints as hash keys, so really it does everything the old one did, does it better, easier, and possibly faster. --- src/tests/hash.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'src/tests/hash.cpp') diff --git a/src/tests/hash.cpp b/src/tests/hash.cpp index 8406439..f9a8f12 100644 --- a/src/tests/hash.cpp +++ b/src/tests/hash.cpp @@ -67,11 +67,9 @@ int main() } printf("Getting\n-------------------\n\n"); - printf("%d\n", sTest.get( names[10] ) ); - printf("%d\n", (int)sTest[names[10]] ); - sTest[names[10]] = 22; - sTest["That one guy"] = 135; - printf("%d\n", (int)sTest[names[10]] ); + + sTest.erase("Homer the Great"); + sTest["Bart's Comet"].erase(); for( Hash::iterator i = sTest.begin(); i != sTest.end(); i++ ) @@ -79,5 +77,23 @@ int main() Hash::iterator j = i; printf("%d: %s\n", (*j).second, (*j).first.c_str() ); } + + for( int j = 0; j < 33; j++ ) + { + if( sTest[names[j]].isFilled() ) + { + if( sTest[names[j]] != j ) + { + printf("'%s' should be %d, is %d\n", + names[j], j, + sTest[names[j]].value() + ); + } + } + else + { + printf("Missing element %d, '%s'\n", j, names[j] ); + } + } } -- cgit v1.2.3