|
Boost-Commit : |
From: daniel_james_at_[hidden]
Date: 2008-07-06 17:07:32
Author: danieljames
Date: 2008-07-06 17:07:31 EDT (Sun, 06 Jul 2008)
New Revision: 47144
URL: http://svn.boost.org/trac/boost/changeset/47144
Log:
I've only got one hash function for release, so no need for its own directory.
Added:
trunk/libs/unordered/examples/fnv1.hpp (props changed)
- copied unchanged from r47143, /trunk/libs/unordered/examples/hash_functions/fnv-1.hpp
Removed:
trunk/libs/unordered/examples/hash_functions/fnv-1.hpp
Deleted: trunk/libs/unordered/examples/hash_functions/fnv-1.hpp
==============================================================================
--- trunk/libs/unordered/examples/hash_functions/fnv-1.hpp 2008-07-06 17:07:31 EDT (Sun, 06 Jul 2008)
+++ (empty file)
@@ -1,66 +0,0 @@
-
-// Copyright 2008 Daniel James.
-// Distributed under the Boost Software License, Version 1.0. (See accompanying
-// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-
-// This code is also released into the public domain.
-
-// Algorithm from: http://www.isthe.com/chongo/tech/comp/fnv/
-
-#include <string>
-
-namespace hash
-{
- template <std::size_t FnvPrime, std::size_t OffsetBasis>
- struct basic_fnv_1
- {
- std::size_t operator()(std::string const& text) const
- {
- std::size_t hash = OffsetBasis;
- for(std::string::const_iterator it = text.begin(), end = text.end();
- it != end; ++it)
- {
- hash *= FnvPrime;
- hash ^= *it;
- }
-
- return hash;
- }
- };
-
- template <std::size_t FnvPrime, std::size_t OffsetBasis>
- struct basic_fnv_1a
- {
- std::size_t operator()(std::string const& text) const
- {
- std::size_t hash = OffsetBasis;
- for(std::string::const_iterator it = text.begin(), end = text.end();
- it != end; ++it)
- {
- hash ^= *it;
- hash *= FnvPrime;
- }
-
- return hash;
- }
- };
-
- // For 32 bit machines:
- const std::size_t fnv_prime = 16777619u;
- const std::size_t fnv_offset_basis = 2166136261u;
-
- // For 64 bit machines:
- // const std::size_t fnv_prime = 1099511628211u;
- // const std::size_t fnv_offset_basis = 14695981039346656037u;
-
- // For 128 bit machines:
- // const std::size_t fnv_prime = 309485009821345068724781401u;
- // const std::size_t fnv_offset_basis = 275519064689413815358837431229664493455u;
-
- // For 256 bit machines:
- // const std::size_t fnv_prime = 374144419156711147060143317175368453031918731002211u;
- // const std::size_t fnv_offset_basis = 100029257958052580907070968620625704837092796014241193945225284501741471925557u;
-
- typedef basic_fnv_1<fnv_prime, fnv_offset_basis> fnv_1;
- typedef basic_fnv_1a<fnv_prime, fnv_offset_basis> fnv_1a;
-}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk