summaryrefslogtreecommitdiff
path: root/src/hashcomp.cpp
diff options
context:
space:
mode:
authorAdam <Adam@drink-coca-cola.info>2010-05-14 20:35:38 -0400
committerAdam <Adam@anope.org>2010-06-18 21:01:53 -0400
commitf049124905bd9f53439293e873003cb027a17b91 (patch)
tree352ed9251fd47055dd770aa2d5eabb20247e4b43 /src/hashcomp.cpp
parent81a45520a773732c9f46785f27aa1956150775d7 (diff)
Rewrote the hashing system to use std::tr1::unordered_map
Diffstat (limited to 'src/hashcomp.cpp')
-rw-r--r--src/hashcomp.cpp43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/hashcomp.cpp b/src/hashcomp.cpp
index 65e546c9c..462064235 100644
--- a/src/hashcomp.cpp
+++ b/src/hashcomp.cpp
@@ -164,3 +164,46 @@ bool sepstream::StreamEnd()
{
return n == tokens.end();
}
+
+/** Return a hash value for a string
+ * @param s The string
+ * @return The hash value
+ */
+size_t hash_compare_std_string::operator()(const std::string &s) const
+{
+ register size_t t = 0;
+
+ for (std::string::const_iterator it = s.begin(); it != s.end(); ++it)
+ t = 5 * t + static_cast<const unsigned char>(*it);
+
+ return t;
+}
+
+/** Return a hash value for a string using case insensitivity
+ * @param s The string
+ * @return The hash value
+ */
+size_t hash_compare_ci_string::operator()(const ci::string &s) const
+{
+ register size_t t = 0;
+
+ for (ci::string::const_iterator it = s.begin(); it != s.end(); ++it)
+ t = 5 * t + ascii_case_insensitive_map[static_cast<const unsigned char>(*it)];
+
+ return t;
+}
+
+/** Return a hash value for a string using RFC1459 case sensitivity rules
+ * @param s The string
+ * @return The hash value
+ */
+size_t hash_compare_irc_string::operator()(const irc::string &s) const
+{
+ register size_t t = 0;
+
+ for (irc::string::const_iterator it = s.begin(); it != s.end(); ++it)
+ t = 5 * t + rfc_case_insensitive_map[static_cast<const unsigned char>(*it)];
+
+ return t;
+}
+