{"id":13822421,"url":"https://github.com/flier/rust-t1ha","last_synced_at":"2025-04-06T11:10:43.976Z","repository":{"id":57669192,"uuid":"173932897","full_name":"flier/rust-t1ha","owner":"flier","description":"Rust implementation for T1HA (Fast Positive Hash)","archived":false,"fork":false,"pushed_at":"2024-02-19T10:19:11.000Z","size":61,"stargazers_count":85,"open_issues_count":0,"forks_count":10,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-23T23:15:37.532Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2019-03-05T11:20:43.000Z","updated_at":"2024-06-20T21:57:39.721Z","dependencies_parsed_at":"2024-06-20T21:57:38.306Z","dependency_job_id":"ea45bdb2-28bf-4328-ac44-98b30f58d0f9","html_url":"https://github.com/flier/rust-t1ha","commit_stats":{"total_commits":42,"total_committers":3,"mean_commits":14.0,"dds":0.04761904761904767,"last_synced_commit":"163460ad90b424e75a5480cfe3c94edafc4883ef"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Frust-t1ha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Frust-t1ha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Frust-t1ha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flier%2Frust-t1ha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flier","download_url":"https://codeload.github.com/flier/rust-t1ha/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247471521,"owners_count":20944158,"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":[],"created_at":"2024-08-04T08:01:59.611Z","updated_at":"2025-04-06T11:10:43.954Z","avatar_url":"https://github.com/flier.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# rust-t1ha [![Continuous integration](https://github.com/flier/rust-t1ha/actions/workflows/ci.yaml/badge.svg)](https://github.com/flier/rust-t1ha/actions/workflows/ci.yaml) [![appveyor](https://ci.appveyor.com/api/projects/status/c5hli7g424r0g49n?svg=true)](https://ci.appveyor.com/project/flier/rust-t1ha) [![crate](https://img.shields.io/crates/v/t1ha.svg)](https://crates.io/crates/t1ha) [![docs](https://docs.rs/t1ha/badge.svg)](https://docs.rs/t1ha)\n\nAn implementation of the [T1HA (Fast Positive Hash)](https://github.com/leo-yuriev/t1ha) hash function.\n\n### Briefly, it is a portable 64-bit hash function:\n\n* Intended for 64-bit little-endian platforms, predominantly for Elbrus and x86_64, but portable and without penalties it can run on any 64-bit CPU.\n* In most cases up to 15% faster than StadtX hash, xxHash, mum-hash, metro-hash, etc. and all others portable hash-functions (which do not use specific hardware tricks).\n* Provides a set of terraced hash functions.\n* Currently not suitable for cryptography.\n* Licensed under [zlib License](https://en.wikipedia.org/wiki/Zlib_License).\n\n## Usage\n\nTo include this crate in your program, add the following to your `Cargo.toml`:\n\n```toml\n[dependencies]\nt1ha = \"0.1\"\n```\n\n### Using `t1ha` in a `HashMap`\n\nThe `T1haHashMap` type alias is the easiest way to use the standard library’s `HashMap` with `t1ha`.\n\n```rust\nuse t1ha::T1haHashMap;\n\nlet mut map = T1haHashMap::default();\nmap.insert(1, \"one\");\nmap.insert(2, \"two\");\n\nmap = T1haHashMap::with_capacity_and_hasher(10, Default::default());\nmap.insert(1, \"one\");\nmap.insert(2, \"two\");\n```\n\n**Note:** the standard library’s `HashMap::new` and `HashMap::with_capacity` are only implemented for the `RandomState` hasher, so using `Default` to get the hasher is the next best option.\n\n### Using `t1ha` in a `HashSet`\n\nSimilarly, `T1haHashSet` is a type alias for the standard library’s `HashSet` with `t1ha.\n\n```rust\nuse t1ha::T1haHashSet;\n\nlet mut set = T1haHashSet::default();\nset.insert(1);\nset.insert(2);\n\nset = T1haHashSet::with_capacity_and_hasher(10, Default::default());\nset.insert(1);\nset.insert(2);\n```\n\n## Performance\n\n`t1ha` can use AES, AVX or AVX2 instructions as hardware acceleration.\n\n | Implementation          | Platform/CPU                           |\n | :---------------------- | :------------------------------------- |\n | `t1ha0_ia32aes_avx()`   | x86 with AES-NI and AVX extensions     |\n | `t1ha0_ia32aes_avx2()`  | x86 with AES-NI and AVX2 extensions    |\n | `t1ha0_ia32aes_noavx()` | x86 with AES-NI without AVX extensions |\n | `t1ha0_32le()`          | 32-bit little-endian                   |\n | `t1h0a_32be()`          | 32-bit big-endian                      |\n | `t1ha1_le()`            | 64-bit little-endian                   |\n | `t1ha1_be()`            | 64-bit big-endian                      |\n | `t1ha2_atonce()`        | 64-bit little-endian                   |\n\nYou could choose the right implementation base on your `target_cpu`.\n\n```sh\n$ RUSTFLAGS=\"-C target-cpu=native\" cargo build\n```\n\n### Benchmark\n\n`rust-t1ha` provide [a rough performance comparison](https://www.reddit.com/r/rust/comments/ayla9m/rust_implementation_for_t1ha_fast_positive_hash/) to other `Rust` implemenation of non-cryptographic hash functions, you can run the benchmark base on your envrionment and usage scenario.\n\n```sh\n$ RUSTFLAGS=\"-C target-cpu=native\" cargo bench\n```\n\n### Native `t1ha` Library\n\n`rust-t1ha` major focus `Rust` implementation, if you intent to use the origin native `t1ha` library, please check [rust-fasthash](https://github.com/flier/rust-fasthash) project and it's benchmark, which provides a suite of non-cryptographic hash functions from [SMHasher](https://github.com/rurban/smhasher/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflier%2Frust-t1ha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflier%2Frust-t1ha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflier%2Frust-t1ha/lists"}