summaryrefslogtreecommitdiff
path: root/indra/llcommon/llhash.h
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2007-01-02 08:33:20 +0000
committerJames Cook <james@lindenlab.com>2007-01-02 08:33:20 +0000
commit420b91db29485df39fd6e724e782c449158811cb (patch)
treeb471a94563af914d3ed3edd3e856d21cb1b69945 /indra/llcommon/llhash.h
Print done when done.
Diffstat (limited to 'indra/llcommon/llhash.h')
-rw-r--r--indra/llcommon/llhash.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/indra/llcommon/llhash.h b/indra/llcommon/llhash.h
new file mode 100644
index 0000000000..fbf059bbcd
--- /dev/null
+++ b/indra/llcommon/llhash.h
@@ -0,0 +1,45 @@
+/**
+ * @file llhash.h
+ * @brief Wrapper for a hash function.
+ *
+ * Copyright (c) 2004-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#ifndef LL_LLHASH_H
+#define LL_LLHASH_H
+
+#include "llpreprocessor.h" // for GCC_VERSION
+
+#if (LL_WINDOWS)
+#include <hash_map>
+#include <algorithm>
+#elif LL_DARWIN || LL_LINUX
+# if GCC_VERSION >= 30400 // gcc 3.4 and up
+# include <ext/hashtable.h>
+# elif __GNUC__ >= 3
+# include <ext/stl_hashtable.h>
+# else
+# include <hashtable.h>
+# endif
+#else
+#error Please define your platform.
+#endif
+
+template<class T> inline size_t llhash(T value)
+{
+#if LL_WINDOWS
+ return stdext::hash_value<T>(value);
+#elif ( (defined _STLPORT_VERSION) || ((LL_LINUX) && (__GNUC__ <= 2)) )
+ std::hash<T> H;
+ return H(value);
+#elif LL_DARWIN || LL_LINUX
+ __gnu_cxx::hash<T> H;
+ return H(value);
+#else
+#error Please define your platform.
+#endif
+}
+
+#endif
+