All Projects → 1ykos → patchmap

1ykos / patchmap

Licence: MIT license
A fast and memory efficient hashmap using sorting to resolve collisions

Programming Languages

HTML
75241 projects
C++
36643 projects - #6 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to patchmap

Leaked
Leaked? 2.1 - A Checking tool for Hash codes, Passwords and Emails leaked
Stars: ✭ 184 (+348.78%)
Mutual labels:  hash
Bcrypt
A Java standalone implementation of the bcrypt password hash function. Based on the Blowfish cipher it is the default password hash algorithm for OpenBSD and other systems including some Linux distributions. Includes a CLI Tool.
Stars: ✭ 207 (+404.88%)
Mutual labels:  hash
Clhash
C library implementing the ridiculously fast CLHash hashing function
Stars: ✭ 220 (+436.59%)
Mutual labels:  hash
Awesome Unique Id
A curated list of awesome Unique IDs
Stars: ✭ 196 (+378.05%)
Mutual labels:  hash
Next Build Id
Easily set your `next build` BUILD_ID to the latest git commit hash
Stars: ✭ 203 (+395.12%)
Mutual labels:  hash
Python Hashes
Interesting (non-cryptographic) hashes implemented in pure Python.
Stars: ✭ 213 (+419.51%)
Mutual labels:  hash
Swifthash
🍕 MD5 in pure Swift
Stars: ✭ 182 (+343.9%)
Mutual labels:  hash
Scrypt
A .NET implementation of scrypt password hash algorithm.
Stars: ✭ 90 (+119.51%)
Mutual labels:  hash
Phash
pHash - the open source perceptual hash library
Stars: ✭ 208 (+407.32%)
Mutual labels:  hash
Nsec
A modern and easy-to-use cryptographic library for .NET Core based on libsodium
Stars: ✭ 217 (+429.27%)
Mutual labels:  hash
Argon2 Browser
Argon2 library compiled for browser runtime
Stars: ✭ 197 (+380.49%)
Mutual labels:  hash
Discohash
👯 Discohash - A super fast and simple hash. 5GB/s serial (depending on hardware). Also in NodeJS
Stars: ✭ 205 (+400%)
Mutual labels:  hash
Hackers Tool Kit
Its a framework filled with alot of options and hacking tools you use directly in the script from brute forcing to payload making im still adding more stuff i now have another tool out called htkl-lite its hackers-tool-kit just not as big and messy to see updates check on my instagram @tuf_unkn0wn or if there are any problems message me on instagram
Stars: ✭ 211 (+414.63%)
Mutual labels:  hash
Dcipher Cli
🔓Crack hashes using online rainbow & lookup table attack services, right from your terminal.
Stars: ✭ 193 (+370.73%)
Mutual labels:  hash
Python Xxhash
Python Binding for xxHash
Stars: ✭ 226 (+451.22%)
Mutual labels:  hash
Highwayhash
Node.js implementation of HighwayHash, Google's fast and strong hash function
Stars: ✭ 183 (+346.34%)
Mutual labels:  hash
Dhash
Python library to calculate the difference hash (perceptual hash) for a given image, useful for detecting duplicates
Stars: ✭ 209 (+409.76%)
Mutual labels:  hash
h2c-rust-ref
Hash to curves - Rust reference implementation
Stars: ✭ 21 (-48.78%)
Mutual labels:  hash
Mercury
Mercury is a hacking tool used to collect information and use the information to further hurt the target
Stars: ✭ 236 (+475.61%)
Mutual labels:  hash
Blake3
A pure-Go implementation of the BLAKE3 cryptographic hash function
Stars: ✭ 216 (+426.83%)
Mutual labels:  hash

patchmap

A fast and memory efficient hashmap using sorting to resolve collisions

It achieves a very good trade-off between memory efficiency and speed for load factors over ~0.5. It can be an almost drop-in replacement for std::unordered_map, with the caveat however that iterators are possibly invalidated by insertions.

Usage:

#include <iostream>
#include "patchmap.hpp"
int main() {
  whash::patchmap<int,int> hash_table;
  hash_table[7] = 77;
  for (const auto& elem : hash_table) {
    std::cout << elem.first << " " << elem.second << std::endl;
  }
}
> g++ -O3 -std=c++17 -DNDEBUG main.cpp

This hashmap is inspired by the 1973 publication "Ordered hash tables". The idea presented there is to resolve collisions via an ordering defined by the keys directly. The patchmap however resolves the collisions with an ordering defined by the hash-value of the keys. So long there are no collisions the keys in a hash table are already in hash-order. When there are collisions in the patchmap this order is upheld by inserting the key-value pairs at the appropriate position, displacing keys that compare greater to the right and keys that compare less to the left, essentially performing a single step of insertion sort. This improves the commonly encountered worst-case complexity of O(n) for lookups to O(log(n)) as a binary search can always be employed on a ordered list with random access. In addition, when the hash values are evenly distributed, which is the case for the hash functions supplied with this library, this allowes for an asymptotic complexity of O(log(-log(1-a))) because an interpolation search can be used to retrieve the entries, performing exceptionally well even when the table is almost full.

The resulting ordering is very similar to the one resulting from linear bidirectional probing with robin hood hashing (see for example sherwood_map) but allowing interpolation search leads to improved upper bounds while retaining the same average complexity and overall performance, exceeding other implementations at high load factors around 96% at the cost of O((1-a)¯²) reordering operations for insertions and deletions however.

If you are interested using this container contact me and I will make it work for you, if it does not just work out of the box. No, just contact me regardless, I'm curious how it works for you!

If you are interested in understanding the patchmap or want to implement it in your favourite programming language you should have a look at patchmap_v0.hpp. This is a oversimplified prototype, to ease the understanding without templates and with binary search instead of interpolation search.

TODO

  • use boosts advanced allocation to make use of expansion and reallocation
  • re-unify sparse_patchmap.hpp and patchmap.hpp
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].