libassetmap  1.0.0
Hash-table based archive format containing compressed data
IHasher.h
1 #ifndef LIBASSETMAP_IHASHER_H
2 #define LIBASSETMAP_IHASHER_H
3 
4 #include <cstdint>
5 #include <string_view>
6 
7 namespace AssetMap {
8  class IHasher {
9  public:
14  [[nodiscard]] virtual uint64_t
15  Hash(std::string_view data) const noexcept = 0;
16 
21  [[nodiscard]] virtual size_t
22  CalcBucket(uint64_t hash, size_t bucketCount) const noexcept = 0;
23 
29  [[nodiscard]] virtual size_t
30  CalcBucketsForItemCount(size_t count) const noexcept = 0;
31 
32  virtual ~IHasher() noexcept = default;
33  };
34 } // namespace AssetMap
35 
36 #endif // LIBASSETMAP_IHASHER_H
AssetMap::IHasher::Hash
virtual uint64_t Hash(std::string_view data) const noexcept=0
Computes an unsigned 64-bit value of an arbitrary string of bytes.
AssetMap::IHasher::CalcBucket
virtual size_t CalcBucket(uint64_t hash, size_t bucketCount) const noexcept=0
Calculates the bucket index from a given hash and bucket count.
AssetMap
Definition: DirectoryMetadata.h:65
AssetMap::IHasher
Definition: IHasher.h:8
AssetMap::IHasher::CalcBucketsForItemCount
virtual size_t CalcBucketsForItemCount(size_t count) const noexcept=0
Computes the preferred number of buckets the implementation wants for a given number of entries that ...