From 2960390f7951eb241754bdaf8295c3cebb9dbfd6 Mon Sep 17 00:00:00 2001 From: Daniel James Date: Sun, 6 Jul 2008 21:06:52 +0000 Subject: [PATCH] Clean up the FNV-1 comments. [SVN r47143] --- examples/hash_functions/fnv-1.hpp | 37 +++++++++++++------------------ 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/examples/hash_functions/fnv-1.hpp b/examples/hash_functions/fnv-1.hpp index a5c63a67..60bf8985 100644 --- a/examples/hash_functions/fnv-1.hpp +++ b/examples/hash_functions/fnv-1.hpp @@ -3,6 +3,8 @@ // 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 @@ -43,29 +45,22 @@ namespace hash } }; - // TODO: Select Basis & Prime base on the size of std::size_t. - // - // 32 bit FNV_prime = 16777619 - // 64 bit FNV_prime = 1099511628211 - // 128 bit FNV_prime = 309485009821345068724781401 - // 256 bit FNV_prime = 374144419156711147060143317175368453031918731002211 - // - // 32 bit offset_basis = 2166136261 - // 64 bit offset_basis = 14695981039346656037 - // 128 bit offset_basis = 275519064689413815358837431229664493455 - // 256 bit offset_basis = 100029257958052580907070968620625704837092796014241193945225284501741471925557 - - const std::size_t fnv_prime = 16777619; - // 64 bit FNV_prime = 1099511628211 - // 128 bit FNV_prime = 309485009821345068724781401 - // 256 bit FNV_prime = 374144419156711147060143317175368453031918731002211 - + // For 32 bit machines: + const std::size_t fnv_prime = 16777619u; const std::size_t fnv_offset_basis = 2166136261u; - // 64 bit offset_basis = 14695981039346656037 - // 128 bit offset_basis = 275519064689413815358837431229664493455 - // 256 bit offset_basis = 100029257958052580907070968620625704837092796014241193945225284501741471925557 + + // 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_1; typedef basic_fnv_1a fnv_1a; - }