From 5bd06d3a02a010d39b3bb50b82507c0fe3e40b38 Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 15 Jul 2014 22:05:36 -0500 Subject: [PATCH] Remove HashTools::HashMap/SpecializedHashMap These are no longer used. Wipe them out. --- common/include/Utilities/HashMap.h | 200 ----------------------------- 1 file changed, 200 deletions(-) diff --git a/common/include/Utilities/HashMap.h b/common/include/Utilities/HashMap.h index e884a05755..1bcc82e1cd 100644 --- a/common/include/Utilities/HashMap.h +++ b/common/include/Utilities/HashMap.h @@ -459,205 +459,5 @@ public: } }; -/// -/// Defines a hashed collection of objects and provides methods for adding, removing, and reading items. -/// -/// -/// This class is for hashing out a set data using objects as keys. Objects should derive from the -/// type, and in either case *must* implement the UnaryHashCode and UnaryEquals -/// unary classes. -/// *Details On Implementing Key Types* -/// -/// Custom hash keying uses what I consider a somewhat contrived method of implementing the Key type; -/// involving a handful of macros in the best case, and a great deal of syntaxical red tape in -/// the worst case. Most cases should fall within the realm of the macros, which make life a lot easier, -/// so that's the only implementation I will cover in detail here (see below for example). -/// -/// Note: -/// For most hashs based on common or fundamental types or types that can be adequately compared using -/// the default equality operator ==, such as int or structs that have no padding alignment concerns, -/// use instead. For string-based hashs, use or . -/// -/// -/// This is an example of making a hashable type out of a struct. This is useful in situations where -/// inheriting the type would cause unnecessary overhead and/or broken C/C++ -/// compatability. -/// -/// struct Point -/// { -/// int x, y; -/// -/// // Empty constructor is necessary for HashMap. -/// // This can either be initialized to zero, or uninitialized as here: -/// Point() {} -/// -/// // Copy Constructor is just always necessary. -/// Point( const Point& src ) : first( src.first ), second( src.second ) {} -/// -/// // Standard content constructor (Not needed by HashMap) -/// Point( int xpos, int ypos ) : x( xpos ), y( ypos ) {} -/// -/// /**** Begin Hashmap Interface Implementation ****/ -/// -/// // HashMap Requires both GetEmptyKey() and GetDeleteKey() instance member -/// // methods to be defined. These act as defaults. The actual values used -/// // can be overridden on an individual HashMap basis via the HashMap constructor. -/// -/// static Point GetEmptyKey() { return Point( -0xffffff, 0xffffff ); } -/// static Point GetDeletedKey() { return Kerning( -0xffffee, 0xffffee ); } -/// -/// // HashMap Requires an Equality Overload. -/// // The inequality overload is not required but is probably a good idea since -/// // orphaned equality (without sibling inequality) operator overloads are ugly code. -/// -/// bool Equals( const Point& right ) const -/// { -/// return ( x == right.x ) && ( y == right.y ); -/// } -/// -/// hash_key_t GetHashCode() const -/// { -/// // This is a decent "universal" hash method for when you have multiple int types: -/// return GetCommonHash( x ) ^ GetCommonHash( y ); -/// } -/// -/// // Use a macro to expose the hash API to the HashMap templates. -/// // This macro creates MakeHashCode and Compare structs, which use the () -/// // operator to create "unary methods" for the GetHashCode and == operator above. -/// // Feeling dizzy yet? Don't worry. Just follow this template. It works! -/// -/// DEFINE_HASH_API( Point ); -/// -/// /**** End HashMap Interface Implementation ****/ -/// }; -/// -/// -template< class Key, class T > -class SpecializedHashMap : public google::dense_hash_map -{ -public: - virtual ~SpecializedHashMap() {} - SpecializedHashMap( int initialCapacity=33, Key emptyKey=Key::GetEmptyKey(), Key deletedKey=Key::GetDeletedKey() ) : - google::dense_hash_map( initialCapacity ) - { - set_empty_key( emptyKey ); - set_deleted_key( deletedKey ); - } - - /// - /// Tries to get a value from this hashmap; or does nothing if the Key does not exist. - /// - /// - /// If found, the value associated with the requested key is copied into the outval - /// parameter. This is a more favorable alternative to the indexer operator since the - /// indexer implementation can and will create new entries for every request that - /// - /*void TryGetValue( const Key& key, T& outval ) const - { - // GCC doesn't like this for some reason -- says const_iterator can't be found. - // Fortunately nothing uses these functions yet, so I just commented them out. --air - const_iterator iter = find( key ); - if( iter != end() ) - outval = iter->second; - }*/ - - const T& GetValue( Key key ) const - { - return (find( key ))->second; - } -}; - -/// -/// This class implements a hashmap that uses fundamental types such as int or std::string -/// as keys. -/// -/// -/// This class is provided so that you don't have to jump through hoops in order to use fundamental types as -/// hash keys. The class isn't suited to the task since it requires the key type to -/// include a set of unary methods. Obviously predicates cannot be added to fundamentals after the fact. :) -/// Note: -/// Do not use char * or wchar_t * as key types. Use std::string and std::wstring -/// instead, as performance of those types will generally be superior due to string length caching. For that -/// matter, don't use this class at all! Use the string-specialized classes and -/// . -/// -template< class Key, class T, class HashFunctor=CommonHashClass > -class HashMap : public google::dense_hash_map -{ - DeclareNoncopyableObject( HashMap ); - - typedef typename google::dense_hash_map _parent; - -public: - using _parent::operator[]; - using _parent::end; - typedef typename _parent::const_iterator const_iterator; - - virtual ~HashMap() {} - - /// - /// Constructor. - /// - /// - /// Both the emptyKeya nd c>deletedKey parameters must be unique values that - /// are *not* used as actual values in the set. - /// - HashMap( const Key& emptyKey, const Key& deletedKey, int initialCapacity=33 ) : - google::dense_hash_map( initialCapacity ) - { - this->set_empty_key( emptyKey ); - this->set_deleted_key( deletedKey ); - } - - /// - /// Tries to get a value from this hashmap; or does nothing if the Key does not exist. - /// - /// - /// If found, the value associated with the requested key is copied into the outval - /// parameter. This is a more favorable alternative to the indexer operator since the - /// indexer implementation can and will create new entries for every request that - /// - bool TryGetValue( const Key& key, T& outval ) const - { - const_iterator iter( this->find(key) ); - if( iter != end() ) - { - outval = iter->second; - return true; - } - return false; - } - - const T& GetValue( Key key ) const - { - return (find( key ))->second; - } - - bool Find( Key key ) const - { - return find(key) != end(); - } -}; - -/// -/// A shortcut class for easy implementation of string-based hash maps. -/// -/// -/// Note: -/// This class does not support Unicode character sets natively. To use Unicode strings as keys, -/// use instead. -/// -template< class T > -class Dictionary : public HashMap -{ -public: - virtual ~Dictionary() {} - - Dictionary( int initialCapacity=33, const std::string& emptyKey = "@@-EMPTY-@@", const std::string& deletedKey = "@@-DELETED-@@" ) - : HashMap( emptyKey, deletedKey, initialCapacity) - { - } -}; - }