summaryrefslogtreecommitdiff
path: root/src/hashcomp.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-06-19 11:54:08 -0400
committerAdam <Adam@anope.org>2010-06-19 11:54:08 -0400
commit52058fe87b4b0475b1775198c725af14e540d355 (patch)
treec3597d6411a006ffbb670d2ce761101b9640e9b6 /src/hashcomp.cpp
parent43e951aed54f838ba55a4c1552214773aee2fb2f (diff)
parentdf9d291bcba9788e51d11424ebaf6f05c26cc80f (diff)
Merge remote branch 'origin/1.9.3' into 1.9
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;
+}
+