https://github.com/lemire/rollinghashcpp
Rolling Hash C++ Library
https://github.com/lemire/rollinghashcpp
hashing universality
Last synced: about 1 year ago
JSON representation
Rolling Hash C++ Library
- Host: GitHub
- URL: https://github.com/lemire/rollinghashcpp
- Owner: lemire
- Created: 2011-03-11T14:19:01.000Z (about 15 years ago)
- Default Branch: master
- Last Pushed: 2024-03-14T13:37:20.000Z (about 2 years ago)
- Last Synced: 2025-04-09T20:15:23.467Z (about 1 year ago)
- Topics: hashing, universality
- Language: C++
- Homepage:
- Size: 92.8 KB
- Stars: 187
- Watchers: 17
- Forks: 33
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Randomized rolling hash functions in C++
[](https://github.com/lemire/rollinghashcpp/actions/workflows/ubuntu22.yml)
License: Apache 2.0
## What is this?
This is a set of C++ classes implementing various recursive n-gram hashing techniques, also called rolling hashing (http://en.wikipedia.org/wiki/Rolling_hash), including:
* Randomized Karp-Rabin (sometimes called Rabin-Karp)
* Hashing by Cyclic Polynomials (also known as Buzhash)
* Hashing by Irreducible Polynomials
This library is used by [khmer](https://github.com/dib-lab/khmer/): the in-memory nucleotide sequence k-mer engine.
These are randomized hash functions, meaning that each time you create a new hasher instance, you will
get new hash values for a given input.
## Code sample
```cpp
const uint n(3);//hash all sequences of 3 characters
const uint L(7); // you need 7 bits
CyclicHash hf(n,L );// if you want 64-bit values replace uint32 by uint64
for(uint32 k = 0; k