Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:17

0001 // Copyright 2018 The Abseil Authors.
0002 //
0003 // Licensed under the Apache License, Version 2.0 (the "License");
0004 // you may not use this file except in compliance with the License.
0005 // You may obtain a copy of the License at
0006 //
0007 //      https://www.apache.org/licenses/LICENSE-2.0
0008 //
0009 // Unless required by applicable law or agreed to in writing, software
0010 // distributed under the License is distributed on an "AS IS" BASIS,
0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0012 // See the License for the specific language governing permissions and
0013 // limitations under the License.
0014 //
0015 // https://code.google.com/p/cityhash/
0016 //
0017 // This file provides a few functions for hashing strings.  All of them are
0018 // high-quality functions in the sense that they pass standard tests such
0019 // as Austin Appleby's SMHasher.  They are also fast.
0020 //
0021 // For 64-bit x86 code, on short strings, we don't know of anything faster than
0022 // CityHash64 that is of comparable quality.  We believe our nearest competitor
0023 // is Murmur3.  For 64-bit x86 code, CityHash64 is an excellent choice for hash
0024 // tables and most other hashing (excluding cryptography).
0025 //
0026 // For 32-bit x86 code, we don't know of anything faster than CityHash32 that
0027 // is of comparable quality.  We believe our nearest competitor is Murmur3A.
0028 // (On 64-bit CPUs, it is typically faster to use the other CityHash variants.)
0029 //
0030 // Functions in the CityHash family are not suitable for cryptography.
0031 //
0032 // Please see CityHash's README file for more details on our performance
0033 // measurements and so on.
0034 //
0035 // WARNING: This code has been only lightly tested on big-endian platforms!
0036 // It is known to work well on little-endian platforms that have a small penalty
0037 // for unaligned reads, such as current Intel and AMD moderate-to-high-end CPUs.
0038 // It should work on all 32-bit and 64-bit platforms that allow unaligned reads;
0039 // bug reports are welcome.
0040 //
0041 // By the way, for some hash functions, given strings a and b, the hash
0042 // of a+b is easily derived from the hashes of a and b.  This property
0043 // doesn't hold for any hash functions in this file.
0044 
0045 #ifndef ABSL_HASH_INTERNAL_CITY_H_
0046 #define ABSL_HASH_INTERNAL_CITY_H_
0047 
0048 #include <stdint.h>
0049 #include <stdlib.h>  // for size_t.
0050 
0051 #include <utility>
0052 
0053 #include "absl/base/config.h"
0054 
0055 namespace absl {
0056 ABSL_NAMESPACE_BEGIN
0057 namespace hash_internal {
0058 
0059 // Hash function for a byte array.
0060 uint64_t CityHash64(const char *s, size_t len);
0061 
0062 // Hash function for a byte array.  For convenience, a 64-bit seed is also
0063 // hashed into the result.
0064 uint64_t CityHash64WithSeed(const char *s, size_t len, uint64_t seed);
0065 
0066 // Hash function for a byte array.  For convenience, two seeds are also
0067 // hashed into the result.
0068 uint64_t CityHash64WithSeeds(const char *s, size_t len, uint64_t seed0,
0069                              uint64_t seed1);
0070 
0071 // Hash function for a byte array.  Most useful in 32-bit binaries.
0072 uint32_t CityHash32(const char *s, size_t len);
0073 
0074 }  // namespace hash_internal
0075 ABSL_NAMESPACE_END
0076 }  // namespace absl
0077 
0078 #endif  // ABSL_HASH_INTERNAL_CITY_H_