Commit 3785d320 authored by Davis King's avatar Davis King

Added comments regarding endianness and hashing.

parent a68c27be
...@@ -37,6 +37,11 @@ namespace dlib ...@@ -37,6 +37,11 @@ namespace dlib
- Each value of seed results in a different hash function being used. - Each value of seed results in a different hash function being used.
(e.g. hash(item,0) should generally not be equal to hash(item,1)) (e.g. hash(item,0) should generally not be equal to hash(item,1))
- uses the murmur_hash3() routine to compute the actual hash. - uses the murmur_hash3() routine to compute the actual hash.
- Note that the returned hash value will be different on big-endian and
little-endian systems since hash() doesn't attempt to perform any byte
swapping of the data contained in item. If you want to always obtain
the same hash then you need to byte swap the elements of item before
passing it to hash().
!*/ !*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -47,11 +52,19 @@ namespace dlib ...@@ -47,11 +52,19 @@ namespace dlib
uint32 seed = 0 uint32 seed = 0
); );
/*! /*!
requires
- T is a standard layout type (e.g. a POD type like int, float,
or a simple struct).
ensures ensures
- returns a 32bit hash of the data stored in item. - returns a 32bit hash of the data stored in item.
- Each value of seed results in a different hash function being used. - Each value of seed results in a different hash function being used.
(e.g. hash(item,0) should generally not be equal to hash(item,1)) (e.g. hash(item,0) should generally not be equal to hash(item,1))
- uses the murmur_hash3() routine to compute the actual hash. - uses the murmur_hash3() routine to compute the actual hash.
- Note that the returned hash value will be different on big-endian and
little-endian systems since hash() doesn't attempt to perform any byte
swapping of the data contained in item. If you want to always obtain
the same hash then you need to byte swap the elements of item before
passing it to hash().
!*/ !*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -62,11 +75,19 @@ namespace dlib ...@@ -62,11 +75,19 @@ namespace dlib
uint32 seed = 0 uint32 seed = 0
); );
/*! /*!
requires
- T and U are standard layout types (e.g. POD types like int, float,
or simple structs).
ensures ensures
- returns a 32bit hash of the data stored in item. - returns a 32bit hash of the data stored in item.
- Each value of seed results in a different hash function being used. - Each value of seed results in a different hash function being used.
(e.g. hash(item,0) should generally not be equal to hash(item,1)) (e.g. hash(item,0) should generally not be equal to hash(item,1))
- uses the murmur_hash3() routine to compute the actual hash. - uses the murmur_hash3() routine to compute the actual hash.
- Note that the returned hash value will be different on big-endian and
little-endian systems since hash() doesn't attempt to perform any byte
swapping of the data contained in item. If you want to always obtain
the same hash then you need to byte swap the elements of item before
passing it to hash().
!*/ !*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
...@@ -77,11 +98,19 @@ namespace dlib ...@@ -77,11 +98,19 @@ namespace dlib
uint32 seed = 0 uint32 seed = 0
); );
/*! /*!
requires
- T and U are standard layout types (e.g. POD types like int, float,
or simple structs).
ensures ensures
- returns a 32bit hash of the data stored in item. - returns a 32bit hash of the data stored in item.
- Each value of seed results in a different hash function being used. - Each value of seed results in a different hash function being used.
(e.g. hash(item,0) should generally not be equal to hash(item,1)) (e.g. hash(item,0) should generally not be equal to hash(item,1))
- uses the murmur_hash3() routine to compute the actual hash. - uses the murmur_hash3() routine to compute the actual hash.
- Note that the returned hash value will be different on big-endian and
little-endian systems since hash() doesn't attempt to perform any byte
swapping of the data contained in item. If you want to always obtain
the same hash then you need to byte swap the elements of item before
passing it to hash().
!*/ !*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
...@@ -705,11 +705,19 @@ namespace dlib ...@@ -705,11 +705,19 @@ namespace dlib
uint32 seed = 0 uint32 seed = 0
); );
/*! /*!
requires
- T is a standard layout type (e.g. a POD type like int, float,
or a simple struct).
ensures ensures
- returns a 32bit hash of the data stored in item. - returns a 32bit hash of the data stored in item.
- Each value of seed results in a different hash function being used. - Each value of seed results in a different hash function being used.
(e.g. hash(item,0) should generally not be equal to hash(item,1)) (e.g. hash(item,0) should generally not be equal to hash(item,1))
- uses the murmur_hash3() routine to compute the actual hash. - uses the murmur_hash3() routine to compute the actual hash.
- Note that the returned hash value will be different on big-endian and
little-endian systems since hash() doesn't attempt to perform any byte
swapping of the data contained in item. If you want to always obtain
the same hash then you need to byte swap the elements of item before
passing it to hash().
!*/ !*/
// ---------------------------------------------------------------------------------------- // ----------------------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment