From 4b8bad3d711f39db84f094edf83c5496a3f02cd6 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Tue, 21 Nov 2006 12:23:13 +0000 Subject: Wow, craziness. Part way through working on the confpair system I got some sudden insperation and completely redid Hash. Now everything but delete is implemented, including typesafe iterators and more. It's really cool, and everyone should check it out and start using it right away! --- src/tests/confpair.cpp | 11 ++++++-- src/tests/hash.cpp | 77 ++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 83 insertions(+), 5 deletions(-) (limited to 'src/tests') diff --git a/src/tests/confpair.cpp b/src/tests/confpair.cpp index 8e03730..fb1b0d3 100644 --- a/src/tests/confpair.cpp +++ b/src/tests/confpair.cpp @@ -5,10 +5,15 @@ using namespace std; int main() { - ConfPair p1("DebugMode"); - p1.value() = true; + ConfPair p1("DebugMode"); + p1.value() = 12; cout << p1.value() << "\n"; - p1.value() = false; + p1.value() = 55; cout << p1.value() << "\n"; + + ConfPairBase &p = p1; + + p = "33.12"; + cout << p.getAsString(); } diff --git a/src/tests/hash.cpp b/src/tests/hash.cpp index d0f5fa6..8406439 100644 --- a/src/tests/hash.cpp +++ b/src/tests/hash.cpp @@ -3,8 +3,81 @@ int main() { - //Hash sTest; + const char *names[]={ + "Homer the Great", + "And Maggie Makes Three", + "Bart's Comet", + "Homie The Clown", + "Bart Vs Australia", + "Homer vs Patty and Selma", + "A star is burns", + "Lisa's Wedding", + "Two Dozen and One Greyhounds", + "The PTA Disbands", + "Round Springfield", + "The Springfield connection", + "Lemon of Troy", + "Who Shot Mr. Burns (Pt. 1)", + "Who Shot Mr. Burns (pt. 2)", + "Radioactive Man", + "Home Sweet Homediddly-dum-doodly", + "Bart Sells His Soul", + "Lisa the Vegetarian", + "Treehouse of horror VI", + "King Size Homer", + "Mother Simpson", + "Sideshow Bob's Last Gleaming", + "The Simpson's 138th Show Spectacular", + "Marge Be Not Proud", + "Team Homer", + "Two Bad Neighbors", + "Scenes From the Class Struggle in Springfield", + "Bart the Fink", + "Lisa the Iconoclast", + "Homer the Smithers", + "The Day the Violence Died", + "A Fish Called Selma", + "Bart on the road", + "22 Short Films about Springfield", + "The Curse of the Flying Hellfish", + "Much Apu about Nothing", + "Homerpalooza", + "The Summer of 4 Ft 2", + "Treehouse of Horror VII", + "You Only Move Twice", + "The Homer They Fall", + "Burns Baby Burns", + "Bart After Dark", + "A Millhouse Divided", + "Lisas Date With Destiny", + "Hurricane Neddy", + "The Mysterious Voyage of Our Homer", + "The Springfield Files", + "The Twisted World of Marge Simpson", + "Mountain of Madness", + NULL + }; - //sTest.hasKey("hello"); + Hash sTest; + + printf("Inserting\n-------------------\n\n"); + for( int j = 0; j < 33; j++ ) + { + sTest[names[j]] = j; + } + + 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]] ); + + for( Hash::iterator i = sTest.begin(); + i != sTest.end(); i++ ) + { + Hash::iterator j = i; + printf("%d: %s\n", (*j).second, (*j).first.c_str() ); + } } -- cgit v1.2.3