Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/foldhash/src/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  convenience.rs

  Sprache: Rust
 

use super::fast::{FixedState, RandomState};

/// Type alias for [`std::collections::HashMap<K, V, foldhash::fast::RandomState>`].
pub type HashMap<K, V> = std::collections::HashMap<K, V, RandomState>;

/// Type alias for [`std::collections::HashSet<T, foldhash::fast::RandomState>`].
pub type HashSet<T> = std::collections::HashSet<T, RandomState>;

/// A convenience extension trait to enable [`HashMap::new`] for hash maps that use `foldhash`.
pub trait HashMapExt {
    /// Creates an empty `HashMap`.
    fn new() -> Self;

    /// Creates an empty `HashMap` with at least the specified capacity.
    fn with_capacity(capacity: usize) -> Self;
}

impl<K, V> HashMapExt for std::collections::HashMap<K, V, RandomState> {
    #[inline(always)]
    fn new() -> Self {
        Self::with_hasher(RandomState::default())
    }

    #[inline(always)]
    fn with_capacity(capacity: usize) -> Self {
        Self::with_capacity_and_hasher(capacity, RandomState::default())
    }
}

impl<K, V> HashMapExt for std::collections::HashMap<K, V, FixedState> {
    #[inline(always)]
    fn new() -> Self {
        Self::with_hasher(FixedState::default())
    }

    #[inline(always)]
    fn with_capacity(capacity: usize) -> Self {
        Self::with_capacity_and_hasher(capacity, FixedState::default())
    }
}

/// A convenience extension trait to enable [`HashSet::new`] for hash sets that use `foldhash`.
pub trait HashSetExt {
    /// Creates an empty `HashSet`.
    fn new() -> Self;

    /// Creates an empty `HashSet` with at least the specified capacity.
    fn with_capacity(capacity: usize) -> Self;
}

impl<T> HashSetExt for std::collections::HashSet<T, RandomState> {
    #[inline(always)]
    fn new() -> Self {
        Self::with_hasher(RandomState::default())
    }

    #[inline(always)]
    fn with_capacity(capacity: usize) -> Self {
        Self::with_capacity_and_hasher(capacity, RandomState::default())
    }
}

impl<T> HashSetExt for std::collections::HashSet<T, FixedState> {
    #[inline(always)]
    fn new() -> Self {
        Self::with_hasher(FixedState::default())
    }

    #[inline(always)]
    fn with_capacity(capacity: usize) -> Self {
        Self::with_capacity_and_hasher(capacity, FixedState::default())
    }
}

Messung V0.5 in Prozent
C=70 H=90 G=80

¤ Dauer der Verarbeitung: 0.17 Sekunden  (vorverarbeitet am  2026-08-25) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.