Movatterモバイル変換


[0]ホーム

URL:


Docs.rs

hashbrown/
lib.rs

1//! This crate is a Rust port of Google's high-performance [SwissTable] hash2//! map, adapted to make it a drop-in replacement for Rust's standard `HashMap`3//! and `HashSet` types.4//!5//! The original C++ version of [SwissTable] can be found [here], and this6//! [CppCon talk] gives an overview of how the algorithm works.7//!8//! [SwissTable]: https://abseil.io/blog/20180927-swisstables9//! [here]: https://github.com/abseil/abseil-cpp/blob/master/absl/container/internal/raw_hash_set.h10//! [CppCon talk]: https://www.youtube.com/watch?v=ncHmEUmJZf41112#![no_std]13#![cfg_attr(14    feature ="nightly",15    feature(16        test,17        core_intrinsics,18        dropck_eyepatch,19        min_specialization,20        extend_one,21        allocator_api,22        slice_ptr_get,23        maybe_uninit_array_assume_init,24        strict_provenance_lints25    )26)]27#![cfg_attr(feature ="rustc-dep-of-std", feature(rustc_attrs))]28#![allow(29    clippy::doc_markdown,30    clippy::module_name_repetitions,31    clippy::must_use_candidate,32    clippy::option_if_let_else,33    clippy::redundant_else,34    clippy::manual_map,35    clippy::missing_safety_doc,36    clippy::missing_errors_doc37)]38#![warn(missing_docs)]39#![warn(rust_2018_idioms)]40#![cfg_attr(feature ="nightly", warn(fuzzy_provenance_casts))]41#![cfg_attr(42    feature ="nightly",43    allow(clippy::incompatible_msrv, internal_features)44)]45#![cfg_attr(46    all(feature ="nightly", target_arch ="loongarch64"),47    feature(stdarch_loongarch)48)]49#![cfg_attr(50    all(feature ="nightly", feature ="default-hasher"),51    feature(hasher_prefixfree_extras)52)]5354#[cfg(test)]55#[macro_use]56extern cratestd;5758#[cfg_attr(test, macro_use)]59#[cfg_attr(feature ="rustc-dep-of-std", allow(unused_extern_crates))]60extern cratealloc;6162#[cfg(feature ="nightly")]63#[cfg(doctest)]64doc_comment::doctest!("../README.md");6566#[macro_use]67modmacros;6869modcontrol;70modhasher;71modraw;72modutil;7374modexternal_trait_impls;75modmap;76#[cfg(feature ="raw-entry")]77modraw_entry;78#[cfg(feature ="rustc-internal-api")]79modrustc_entry;80modscopeguard;81modset;82modtable;8384pub usecrate::hasher::DefaultHashBuilder;85#[cfg(feature ="default-hasher")]86pub usecrate::hasher::DefaultHasher;8788pub modhash_map {89//! A hash map implemented with quadratic probing and SIMD lookup.90pub usecrate::map::*;9192#[cfg(feature ="rustc-internal-api")]93pub usecrate::rustc_entry::*;9495#[cfg(feature ="rayon")]96/// [rayon]-based parallel iterator types for hash maps.97    /// You will rarely need to interact with it directly unless you have need98    /// to name one of the iterator types.99    ///100    /// [rayon]: https://docs.rs/rayon/1.0/rayon101pub modrayon {102pub usecrate::external_trait_impls::rayon::map::*;103    }104}105pub modhash_set {106//! A hash set implemented as a `HashMap` where the value is `()`.107pub usecrate::set::*;108109#[cfg(feature ="rayon")]110/// [rayon]-based parallel iterator types for hash sets.111    /// You will rarely need to interact with it directly unless you have need112    /// to name one of the iterator types.113    ///114    /// [rayon]: https://docs.rs/rayon/1.0/rayon115pub modrayon {116pub usecrate::external_trait_impls::rayon::set::*;117    }118}119pub modhash_table {120//! A hash table implemented with quadratic probing and SIMD lookup.121pub usecrate::table::*;122123#[cfg(feature ="rayon")]124/// [rayon]-based parallel iterator types for hash tables.125    /// You will rarely need to interact with it directly unless you have need126    /// to name one of the iterator types.127    ///128    /// [rayon]: https://docs.rs/rayon/1.0/rayon129pub modrayon {130pub usecrate::external_trait_impls::rayon::table::*;131    }132}133134pub usecrate::map::HashMap;135pub usecrate::set::HashSet;136pub usecrate::table::HashTable;137138#[cfg(feature ="equivalent")]139pub useequivalent::Equivalent;140141// This is only used as a fallback when building as part of `std`.142#[cfg(not(feature ="equivalent"))]143/// Key equivalence trait.144///145/// This trait defines the function used to compare the input value with the146/// map keys (or set values) during a lookup operation such as [`HashMap::get`]147/// or [`HashSet::contains`].148/// It is provided with a blanket implementation based on the149/// [`Borrow`](core::borrow::Borrow) trait.150///151/// # Correctness152///153/// Equivalent values must hash to the same value.154pub traitEquivalent<K:?Sized> {155/// Checks if this value is equivalent to the given key.156    ///157    /// Returns `true` if both values are equivalent, and `false` otherwise.158    ///159    /// # Correctness160    ///161    /// When this function returns `true`, both `self` and `key` must hash to162    /// the same value.163fnequivalent(&self, key:&K) -> bool;164}165166#[cfg(not(feature ="equivalent"))]167impl<Q:?Sized, K:?Sized> Equivalent<K>forQ168where169Q: Eq,170    K: core::borrow::Borrow<Q>,171{172fnequivalent(&self, key:&K) -> bool {173self== key.borrow()174    }175}176177/// The error type for `try_reserve` methods.178#[derive(Clone, PartialEq, Eq, Debug)]179pub enumTryReserveError {180/// Error due to the computed capacity exceeding the collection's maximum181    /// (usually `isize::MAX` bytes).182CapacityOverflow,183184/// The memory allocator returned an error185AllocError {186/// The layout of the allocation request that failed.187layout:alloc::alloc::Layout,188    },189}

[8]ページ先頭

©2009-2025 Movatter.jp