Remove HashTools::IHashable/CommonComparisonClass

These are no longer used.
This commit is contained in:
Ryan Houdek 2014-07-15 22:08:11 -05:00
parent abd605a066
commit 0c1087a2e5
1 changed files with 0 additions and 81 deletions

View File

@ -359,86 +359,5 @@ public:
}; };
/// <summary>
/// This class contains comparison methods for most fundamental types; and is used by the CommonHashMap class.
/// </summary>
/// <remarks>
/// The predicates of this class do standard equality comparisons between fundamental C/STL types such as
/// <c>int, float</c>, and <c>std::string.</c> Usefulness of this class outside the <see cref="CommonHashMap"/>
/// class is limited.
/// </remarks>
/// <seealso cref="CommonHashMap">
struct CommonComparisonClass
{
bool operator()(const char* s1, const char* s2) const
{
return (s1 == s2) || (s1 && s2 && strcmp(s1, s2) == 0);
}
};
/// <summary>
/// An interface for classes that implement hashmap functionality.
/// </summary>
/// <remarks>
/// This class provides interface methods for getting th hashcode of a class and checking for object
/// equality. It's general intent is for use in situations where you have to store *non-similar objects*
/// in a single unified hash map. As all object instances derive from this type, it allows the equality
/// comparison to use typeid or dynamic casting to check for type similarity, and then use more detailed
/// equality checks for similar types.
/// </remarks>
class IHashable
{
public:
/// Obligatory Virtual destructor mess!
virtual ~IHashable() {};
/// <summary>
/// Your basic no-thrills equality comparison; using a pointer comparison by default.
/// </summary>
/// <remarks>
/// This method uses a pointer comparison by default, which is the only way to really compare objects
/// of unrelated types or of derrived types. When implementing this method, you may want to use typeid comparisons
/// if you want derived types to register as being non-equal, or <c>dynamic_cast</c> for a more robust
/// base-class comparison (illustrated in the example below).
/// Note:
/// It's recommended important to always do a pointer comparison as the first step of any object equality check.
/// It is fast and easy, and 100% reliable.
/// </remarks>
/// <example>
/// Performing non-pointer comparisons:
/// <code>
/// class Hasher : IHashable
/// {
/// int someValue;
///
/// virtual bool Equals( const IHashable& right ) const
/// {
/// // Use pointer comparison first since it's fast and accurate:
/// if( &right == this ) return true;
///
/// Hasher* them = dynamic_cast&lt;Hasher*&gt;( right );
/// if( them == NULL ) return false;
/// return someValue == them->SomeValue;
/// }
/// }
/// </code>
/// </example>
virtual bool Equals( const IHashable& right ) const
{
return ( &right == this ); // pointer comparison.
}
/// <summary>
/// Returns a hash value for this object; by default the hash of its pointer address.
/// </summary>
/// <remarks>
/// </remarks>
/// <seealso cref="HashMap"/>
virtual hash_key_t GetHashCode() const
{
return GetCommonHash( this );
}
};
} }