Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rust port of Google's SwissTable hash map

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
NotificationsYou must be signed in to change notification settings

rust-lang/hashbrown

Build StatusCrates.ioDocumentationRust

This crate is a Rust port of Google's high-performanceSwissTable hashmap, adapted to make it a drop-in replacement for Rust's standardHashMapandHashSet types.

The original C++ version of SwissTable can be foundhere, and thisCppCon talk gives an overview of how the algorithm works.

Since Rust 1.36, this is now theHashMap implementation for the Rust standardlibrary. However you may still want to use this crate instead since it worksin environments withoutstd, such as embedded systems and kernels.

Features

  • Drop-in replacement for the standard libraryHashMap andHashSet types.
  • Usesfoldhash as the default hasher, which is much faster than SipHash.However, foldhash doesnot provide the same level of HashDoS resistance as SipHash, so if that is important to you, you might want to consider using a different hasher.
  • Around 2x faster than the previous standard libraryHashMap.
  • Lower memory usage: only 1 byte of overhead per entry instead of 8.
  • Compatible with#[no_std] (but requires a global allocator with thealloc crate).
  • Empty hash maps do not allocate any memory.
  • SIMD lookups to scan multiple hash entries in parallel.

Usage

Add this to yourCargo.toml:

[dependencies]hashbrown ="0.16"

Then:

use hashbrown::HashMap;letmut map =HashMap::new();map.insert(1,"one");

Flags

This crate has the following Cargo features:

  • nightly: Enables nightly-only features including:#[may_dangle].
  • serde: Enables serde serialization support.
  • rayon: Enables rayon parallel iterator support.
  • equivalent: Allows comparisons to be customized with theEquivalent trait. (enabled by default)
  • raw-entry: Enables access to the deprecatedRawEntry API.
  • inline-more: Adds inline hints to most functions, improving run-time performance at the costof compilation time. (enabled by default)
  • default-hasher: Compiles with foldhash as default hasher. (enabled by default)
  • allocator-api2: Enables support for allocators that supportallocator-api2. (enabled by default)

License

Licensed under either of:

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submittedfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without anyadditional terms or conditions.

About

Rust port of Google's SwissTable hash map

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Security policy

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp