Skip to content

sushant-wayal/stringhash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StringHash Library

A high-performance C++ header-only library for string hashing with rolling hash functionality.

Features

  • Rolling string hash implementation
  • Multiple hash support
  • Template-based for flexibility
  • Header-only library (easy to integrate)
  • Support for adding/removing characters from both ends

Installation

Using CMake

git clone https://github.com/sushant-wayal/stringhash.git
cd stringhash
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local
cmake --build . --target install

Using vcpkg

vcpkg install stringhash

Manual Installation

Simply copy the include folder to your project and add it to your include path.

Usage

#include <stringhash>
#include <iostream>
#include <vector>

int main() {
    long long modNum = 1e9 + 7;
    std::vector<long long> p = {31};
    std::vector<long long> mod = {modNum};
    
    stringHash<long long> h("abc", 0, 2, p, mod);
    std::cout << h.getHash()[0] << std::endl;
    
    return 0;
}

CMake Integration

After installation, you can use the library in your CMake project:

find_package(stringhash REQUIRED)
target_link_libraries(your_target stringhash::stringhash)

License

MIT License - see LICENSE file for details.

A header-only C++ library for efficient string hashing.

Example

#include <sushant-wayal/stringhash>
#include <iostream>
using namespace std;

int main() {
    vector<long long> p = {31}, mod = {1e9+7};
    stringHash<long long> h("abc", 0, 2, p, mod);
    cout << h.getHash()[0] << endl;
}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published