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

Quelle  cached_owned.rs

  Sprache: Rust
 

// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).

use super::*;
use crate::error::ZeroTrieBuildError;
use alloc::collections::btree_map::Entry;
use alloc::collections::BTreeMap;
use alloc::vec::Vec;

/// Helper class for caching the results of multiple [`PerfectByteHashMap`] calculations.
pub struct PerfectByteHashMapCacheOwned {
    // Note: This should probably be a HashMap but that isn't in `alloc`
    data: BTreeMap<Vec<u8>, PerfectByteHashMap<Vec<u8>>>,
}

impl PerfectByteHashMapCacheOwned {
    /// Creates a new empty instance.
    pub fn new_empty() -> Self {
        Self {
            data: BTreeMap::new(),
        }
    }

    /// Gets the [`PerfectByteHashMap`] for the given bytes, calculating it if necessary.
    pub fn try_get_or_insert(
        &mut self,
        keys: Vec<u8>,
    ) -> Result<&PerfectByteHashMap<[u8]>, ZeroTrieBuildError> {
        let mut_phf = match self.data.entry(keys) {
            Entry::Vacant(entry) => {
                let value = PerfectByteHashMap::try_new(entry.key())?;
                entry.insert(value)
            }
            Entry::Occupied(entry) => entry.into_mut(),
        };
        Ok(mut_phf.as_borrowed())
    }
}

Messung V0.5 in Prozent
C=96 H=99 G=97

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© 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.