X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=libs%2Fcontainer%2Fhashtable.cpp;h=edcaff637bdca4b646ea8f21d5e6b65ef35f7d0d;hb=34cbf87edef249d8a4732db54f233ba4ffbea3d4;hp=e4d02c934c99f9cb74de4dd52e0d3b4e909ea982;hpb=bfc8a12a6b315ae261101a34db8ba1b682c67bb7;p=xonotic%2Fnetradiant.git diff --git a/libs/container/hashtable.cpp b/libs/container/hashtable.cpp index e4d02c93..edcaff63 100644 --- a/libs/container/hashtable.cpp +++ b/libs/container/hashtable.cpp @@ -1,65 +1,62 @@ /* -Copyright (C) 2001-2006, William Joseph. -All Rights Reserved. + Copyright (C) 2001-2006, William Joseph. + All Rights Reserved. -This file is part of GtkRadiant. + This file is part of GtkRadiant. -GtkRadiant is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + GtkRadiant is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -GtkRadiant is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + GtkRadiant is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with GtkRadiant; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ + You should have received a copy of the GNU General Public License + along with GtkRadiant; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ #include "hashtable.h" -#if defined(_DEBUG) || defined(DOXYGEN) +#if defined( _DEBUG ) || defined( DOXYGEN ) #include "hashfunc.h" namespace ExampleHashTable { - void testStuff() - { - // HashTable example - typedef HashTable MyHashTable; - MyHashTable hashtable; - hashtable["bleh"] = 5; - hashtable.insert("blah", 17); - hashtable["foo"] = 99; - hashtable.insert("bar", 23); - - int bleh = (*hashtable.find("bleh")).value; // 5 - int blah = hashtable["blah"]; // 17 - hashtable.erase("foo"); - MyHashTable::iterator barIter = hashtable.find("bar"); - hashtable.erase(barIter); - - for(MyHashTable::iterator i = hashtable.begin(); i != hashtable.end(); ++i) - { - if((*i).key != "bleh") - { - ++hashtable["count"]; // insertion does not invalidate iterators - } - } - // end example - } +void testStuff(){ + // HashTable example + typedef HashTable MyHashTable; + MyHashTable hashtable; + hashtable["bleh"] = 5; + hashtable.insert( "blah", 17 ); + hashtable["foo"] = 99; + hashtable.insert( "bar", 23 ); + + int bleh = ( *hashtable.find( "bleh" ) ).value; // 5 + int blah = hashtable["blah"]; // 17 + hashtable.erase( "foo" ); + MyHashTable::iterator barIter = hashtable.find( "bar" ); + hashtable.erase( barIter ); + + for ( MyHashTable::iterator i = hashtable.begin(); i != hashtable.end(); ++i ) + { + if ( ( *i ).key != "bleh" ) { + ++hashtable["count"]; // insertion does not invalidate iterators + } + } + // end example +} - struct Always - { - Always() - { - testStuff(); - } - } always; +struct Always +{ + Always(){ + testStuff(); + } +} always; } #endif