Make hash_set and hash_map available in namespace zypp.
authorMichael Andres <ma@suse.de>
Mon, 27 Nov 2006 23:15:38 +0000 (23:15 +0000)
committerMichael Andres <ma@suse.de>
Mon, 27 Nov 2006 23:15:38 +0000 (23:15 +0000)
Added hash function for std::string.

zypp/base/Hash.h [new file with mode: 0644]
zypp/base/Makefile.am

diff --git a/zypp/base/Hash.h b/zypp/base/Hash.h
new file mode 100644 (file)
index 0000000..3946a1b
--- /dev/null
@@ -0,0 +1,47 @@
+/*---------------------------------------------------------------------\
+|                          ____ _   __ __ ___                          |
+|                         |__  / \ / / . \ . \                         |
+|                           / / \ V /|  _/  _/                         |
+|                          / /__ | | | | | |                           |
+|                         /_____||_| |_| |_|                           |
+|                                                                      |
+\---------------------------------------------------------------------*/
+/** \file      zypp/base/Hash.h
+ *
+*/
+#ifndef ZYPP_BASE_HASH_H
+#define ZYPP_BASE_HASH_H
+
+#include <string>
+
+#include <ext/hash_set>
+#include <ext/hash_map>
+#include <ext/hash_fun.h>
+
+///////////////////////////////////////////////////////////////////
+namespace __gnu_cxx
+{ /////////////////////////////////////////////////////////////////
+
+  /** Specialize hash function for std::string. */
+  template<>
+    struct hash<std::string>
+    {
+      size_t operator()( const std::string & __s ) const
+      { return __stl_hash_string(__s.c_str()); }
+    };
+
+  /////////////////////////////////////////////////////////////////
+} // namespace __gnu_cxx
+///////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+namespace zypp
+{ /////////////////////////////////////////////////////////////////
+
+  using __gnu_cxx::hash_set;
+  using __gnu_cxx::hash_map;
+
+  /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+#endif // ZYPP_BASE_HASH_H
index 990475a..c8c5f8f 100644 (file)
@@ -23,6 +23,7 @@ baseinclude_HEADERS = \
        Function.h      \
        Functional.h    \
        Iterator.h      \
+       Hash.h          \
        Logger.h        \
        LogTools.h      \
        LogControl.h    \