diff options
author | Adam <Adam@anope.org> | 2011-10-26 14:31:58 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2011-10-26 14:31:58 -0400 |
commit | 8334128680c26cec69bd1098c11d36fd716b99c1 (patch) | |
tree | c2cff752378279e68a1571f8acaee74300977306 | |
parent | 7c62de1f27ee21e41b7655e9d82a227f6e2cf2b5 (diff) |
Removed the old unordered_map code
-rw-r--r-- | include/hashcomp.h | 90 | ||||
-rw-r--r-- | src/hashcomp.cpp | 90 |
2 files changed, 0 insertions, 180 deletions
diff --git a/include/hashcomp.h b/include/hashcomp.h index c36211cde..d78b01857 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -33,34 +33,6 @@ namespace Anope class string; } -#ifndef _WIN32 -# if defined(__GNUC__) && __GNUC__ >= 4 -/* GCC4+ has deprecated hash_map and uses tr1. But of course, uses a different include to MSVC. */ -# include <tr1/unordered_map> -# define unordered_map_namespace std::tr1 -# else /* GCC ver < 4 */ -# include <ext/hash_map> -/* Oddball linux namespace for hash_map */ -# define unordered_map_namespace __gnu_cxx -# define unordered_map hash_map -# endif -#else -# if _MSC_VER >= 1600 -/* MSVC 2010+ has tr1. Though MSVC and GCC use different includes! */ -# include <unordered_map> -# define unordered_map_namespace std::tr1 -# else -# include <hash_map> -# define unordered_map_namespace -template<typename Key, typename Type, typename Compare, typename Unused = void> -class unordered_map : public stdext::hash_map<Key, Type, Compare> -{ - public: - unordered_map() : hash_map() { } -}; -# endif -#endif - /******************************************************* * This file contains classes and templates that deal * with the comparison and hashing of 'irc strings'. @@ -167,23 +139,6 @@ namespace irc /** This typedef declares irc::string based upon irc_char_traits. */ typedef std::basic_string<char, irc_char_traits, std::allocator<char> > string; - - /** Used to hash irc::strings for unordered_map - */ - struct CoreExport hash - { - /* VS 2008 specific code */ - enum { bucket_size = 4, min_buckets = 8 }; - bool operator()(const Anope::string &s1, const Anope::string &s2) const; - /* End VS 2008 specific code */ - - /** Hash an irc::string for unordered_map - * @param s The string - * @return A hash value for the string - */ - size_t operator()(const irc::string &s) const; - size_t operator()(const Anope::string &s) const; - }; } /** The ci namespace contains a number of helper classes. @@ -238,55 +193,10 @@ namespace ci /** This typedef declares ci::string based upon ci_char_traits. */ typedef std::basic_string<char, ci_char_traits, std::allocator<char> > string; - - /** Used to hash ci::strings for unordered_map - */ - struct CoreExport hash - { - /* VS 2008 specific code */ - enum { bucket_size = 4, min_buckets = 8 }; - bool operator()(const Anope::string &s1, const Anope::string &s2) const; - /* End VS 2008 specific code */ - - /** Hash a ci::string for unordered_map - * @param s The string - * @return A hash value for the string - */ - size_t operator()(const ci::string &s) const; - size_t operator()(const Anope::string &s) const; - }; } namespace std { - /** An overload for std::equal_to<ci::string> that uses Anope::string, passed for the fourth temmplate - * argument for unordered_map - */ - template<> struct CoreExport equal_to<ci::string> - { - public: - /** Compare two Anope::strings as ci::strings - * @paarm s1 The first string - * @param s2 The second string - * @return true if they are equal - */ - bool operator()(const Anope::string &s1, const Anope::string &s2) const; - }; - - /** An overload for std::equal_to<irc::string> that uses Anope::string, passed for the fourth template - * argument for unorderd_map - */ - template<> struct CoreExport equal_to<irc::string> - { - public: - /** Compare two Anope::strings as irc::strings - * @param s1 The first string - * @param s2 The second string - * @return true if they are equal - */ - bool operator()(const Anope::string &s1, const Anope::string &s2) const; - }; - /** An overload for std::less<ci::string> that uses Anope::string, passed for the third template argument * to std::map and std::multimap */ diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp index 7881f2c7a..cfffd5a10 100644 --- a/src/hashcomp.cpp +++ b/src/hashcomp.cpp @@ -26,26 +26,6 @@ * */ -/* VS 2008 specific function */ -bool Anope::hash::operator()(const Anope::string &s1, const Anope::string &s2) const -{ - return s1.str().compare(s2.str()) < 0; -} - -/** Hash an Anope::string for unordered_map - * @param s The string - * @return A hash value for the string - */ -bool Anope::hash::operator()(const Anope::string &s) const -{ - register size_t t = 0; - - for (Anope::string::const_iterator it = s.begin(), it_end = s.end(); it != it_end; ++it) - t = 5 * t + *it; - - return t; -} - bool irc::irc_char_traits::eq(char c1st, char c2nd) { return rfc_case_insensitive_map[static_cast<unsigned char>(c1st)] == rfc_case_insensitive_map[static_cast<unsigned char>(c2nd)]; @@ -87,31 +67,6 @@ const char *irc::irc_char_traits::find(const char *s1, int n, char c) return n >= 0 ? s1 : NULL; } -/* VS 2008 specific function */ -bool irc::hash::operator()(const Anope::string &s1, const Anope::string &s2) const -{ - return s1.irc_str().compare(s2.irc_str()) < 0; -} - -/** Hash an irc::string for unordered_map - * @param s The string - * @return A hash value for the string - */ -size_t irc::hash::operator()(const irc::string &s) const -{ - register size_t t = 0; - - for (irc::string::const_iterator it = s.begin(), it_end = s.end(); it != it_end; ++it) - t = 5 * t + rfc_case_insensitive_map[static_cast<const unsigned char>(*it)]; - - return t; -} - -size_t irc::hash::operator()(const Anope::string &s) const -{ - return operator()(s.irc_str()); -} - bool ci::ci_char_traits::eq(char c1st, char c2nd) { return ascii_case_insensitive_map[static_cast<unsigned char>(c1st)] == ascii_case_insensitive_map[static_cast<unsigned char>(c2nd)]; @@ -153,51 +108,6 @@ const char *ci::ci_char_traits::find(const char *s1, int n, char c) return n >= 0 ? s1 : NULL; } -/* VS 2008 specific function */ -bool ci::hash::operator()(const Anope::string &s1, const Anope::string &s2) const -{ - return s1.ci_str().compare(s2.ci_str()) < 0; -} - -/** Hash a ci::string for unordered_map - * @param s The string - * @return A hash value for the string - */ -size_t ci::hash::operator()(const ci::string &s) const -{ - register size_t t = 0; - - for (ci::string::const_iterator it = s.begin(), it_end = s.end(); it != it_end; ++it) - t = 5 * t + ascii_case_insensitive_map[static_cast<const unsigned char>(*it)]; - - return t; -} - -size_t ci::hash::operator()(const Anope::string &s) const -{ - return operator()(s.ci_str()); -} - -/** Compare two Anope::strings as ci::strings - * @param s1 The first string - * @param s2 The second string - * @return true if they are equal - */ -bool std::equal_to<ci::string>::operator()(const Anope::string &s1, const Anope::string &s2) const -{ - return s1.ci_str() == s2.ci_str(); -} - -/** Compare two Anope::strings as irc::strings - * @param s1 The first string - * @param s2 The second string - * @return true if they are equal - */ -bool std::equal_to<irc::string>::operator()(const Anope::string &s1, const Anope::string &s2) const -{ - return s1.irc_str() == s2.irc_str(); -} - /** Compare two Anope::strings as ci::strings and find which one is less * @param s1 The first string * @param s2 The second string |