libassetmap  1.0.0
Hash-table based archive format containing compressed data
Public Member Functions | List of all members
AssetMap::CityHash Class Reference
Inheritance diagram for AssetMap::CityHash:
Inheritance graph
[legend]
Collaboration diagram for AssetMap::CityHash:
Collaboration graph
[legend]

Public Member Functions

 CityHash (float bucketRatio=0.75f)
 Constructs an instance of the CityHash class. More...
 
uint64_t Hash (std::string_view data) const noexcept override
 Compute the hash of a given string of bytes. More...
 
size_t CalcBucket (uint64_t hash, size_t bucketCount) const noexcept override
 Calculates the bucket to index given a hash and total bucket size. More...
 
size_t CalcBucketsForItemCount (size_t count) const noexcept override
 Calculates the total number of buckets that should be created for total file count. More...
 

Constructor & Destructor Documentation

◆ CityHash()

AssetMap::CityHash::CityHash ( float  bucketRatio = 0.75f)
explicit

Constructs an instance of the CityHash class.

This class does not allocate anything. An optional bucket ratio can be specified which is used by CalcBucketsForItemCount.

Parameters
bucketRatioSpecifies the desired ratio of items:buckets.

Member Function Documentation

◆ CalcBucket()

size_t AssetMap::CityHash::CalcBucket ( uint64_t  hash,
size_t  bucketCount 
) const
overridevirtualnoexcept

Calculates the bucket to index given a hash and total bucket size.

The exact method of calculation uses floating point operations as this produced mildly better distribution of buckets.

Parameters
hashA hash previously obtained through a call to CityHash::Hash
bucketCountThe total number of buckets that exist.
Returns
A value in the range 0 to bucketCount-1

Implements AssetMap::IHasher.

◆ CalcBucketsForItemCount()

size_t AssetMap::CityHash::CalcBucketsForItemCount ( size_t  count) const
overridevirtualnoexcept

Calculates the total number of buckets that should be created for total file count.

This implementation simply takes count and divides it by bucketRatio

Parameters
countThe total number of entries that will be hashed.
Returns
A value indicating the preferred number of buckets.

Implements AssetMap::IHasher.

◆ Hash()

uint64_t AssetMap::CityHash::Hash ( std::string_view  data) const
overridevirtualnoexcept

Compute the hash of a given string of bytes.

Parameters
dataA string of data to digest.
Returns
A 64-bit hash computed by CityHash.

Implements AssetMap::IHasher.


The documentation for this class was generated from the following file: