{"id":16572771,"url":"https://github.com/lemire/rollinghashcpp","last_synced_at":"2025-04-09T20:15:28.686Z","repository":{"id":1407949,"uuid":"1468126","full_name":"lemire/rollinghashcpp","owner":"lemire","description":"Rolling Hash C++ Library","archived":false,"fork":false,"pushed_at":"2024-03-14T13:37:20.000Z","size":95,"stargazers_count":187,"open_issues_count":2,"forks_count":33,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-09T20:15:23.467Z","etag":null,"topics":["hashing","universality"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lemire.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-03-11T14:19:01.000Z","updated_at":"2025-04-03T11:07:43.000Z","dependencies_parsed_at":"2024-10-26T20:28:58.086Z","dependency_job_id":"ceaa6bdb-269a-46db-b108-2797f822f1c4","html_url":"https://github.com/lemire/rollinghashcpp","commit_stats":{"total_commits":45,"total_committers":4,"mean_commits":11.25,"dds":0.0888888888888889,"last_synced_commit":"14ec027b2ba58d70f36df88ff6f7839c34eaaade"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Frollinghashcpp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Frollinghashcpp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Frollinghashcpp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemire%2Frollinghashcpp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemire","download_url":"https://codeload.github.com/lemire/rollinghashcpp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103872,"owners_count":21048245,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hashing","universality"],"created_at":"2024-10-11T21:28:33.203Z","updated_at":"2025-04-09T20:15:28.661Z","avatar_url":"https://github.com/lemire.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Randomized rolling hash functions in C++\n[![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)\n\nLicense: Apache 2.0\n\n\n## What is this?\n\nThis 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:\n\n*   Randomized Karp-Rabin (sometimes called Rabin-Karp)\n*   Hashing by Cyclic Polynomials (also known as Buzhash)\n*   Hashing by Irreducible Polynomials\n\nThis library is used by [khmer](https://github.com/dib-lab/khmer/): the in-memory nucleotide sequence k-mer engine.\n \n\nThese are randomized hash functions, meaning that each time you create a new hasher instance, you will\nget new hash values for a given input.\n\n##  Code sample\n```cpp\n\n        const uint n(3);//hash all sequences of 3 characters\n        const uint L(7); // you need 7 bits\n        CyclicHash\u003cuint32\u003e hf(n,L );// if you want 64-bit values replace uint32 by uint64\n        for(uint32 k = 0; k\u003cn;++k) {\n                  chartype c = ... ; // grab some character\n                  hf.eat(c); // feed it to the hasher\n        }\n        while(...) { // go over your string\n           hf.hashvalue; // at all times, this contains the hash value\n           chartype c = ... ;// point to the next character\n           chartype out = ...; // character we want to forget\n           hf.update(out,c); // update hash value\n        }\n        hf.reset(); // you can now hash a new string\n```\n\n\n##  Requirements\n\nA recent GNU GCC C++ compiler or a recent CLANG.\n\n##  What should I do after I download it?\n\nIt is a conventional Cmake projet.\n\n```\ncmake -B build\ncmake --build build\nctest --test-dir build\n```\n\n\n## Nim version\n\nSee [Cyclic-Polynomial-Hash](https://github.com/MarcAzar/Cyclic-Polynomial-Hash) for a similar library written in Nim.\n\n##  References\n\n* Daniel Lemire, Owen Kaser: Recursive n-gram hashing is pairwise independent, at best, Computer Speech \u0026 Language, Volume 24, Issue 4, October 2010, Pages 698-710 http://arxiv.org/abs/0705.4676\n* Daniel Lemire, The universality of iterated hashing over variable-length strings, Discrete Applied Mathematics 160 (4-5), 2012. http://arxiv.org/abs/1008.1715\n* Owen Kaser and Daniel Lemire, Strongly universal string hashing is fast, Computer Journal (2014) 57 (11): 1624-1638. http://arxiv.org/abs/1202.4961\n\n\nThis work has been used in genomics, see\n\n\n* Ilia Minkin, Son Pham, Paul Medvedev, TwoPaCo: an efficient algorithm to build the compacted de Bruijn graph from many complete genomes, Bioinformatics (to appear). https://doi.org/10.1093/bioinformatics/btw609 and http://github.com/medvedevgroup/TwoPaCo\n* Xiaofei Zhao, BinDash, software for fast genome distance estimation on a typical personal laptop, Bioinformatics. https://academic.oup.com/bioinformatics/article/35/4/671/5058094?login=true and https://github.com/zhaoxiaofei/bindash?tab=readme-ov-file \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemire%2Frollinghashcpp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemire%2Frollinghashcpp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemire%2Frollinghashcpp/lists"}