An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          

# Randomized rolling hash functions in C++
[![Ubuntu 22.04 CI (GCC 11)](https://github.com/lemire/rollinghashcpp/actions/workflows/ubuntu22.yml/badge.svg)](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