Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/third_party/rust/litemap/examples/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  litemap_bincode.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 ).

// LiteMap is intended as a small and low-memory drop-in replacement for
// HashMap. This example demonstrates how it works with Serde.

#![no_main] // https://github.com/unicode-org/icu4x/issues/395

icu_benchmark_macros::static_setup!();

use litemap::LiteMap;

const DATA: [(&str, &str); 11] = [
    ("ar""Arabic"),
    ("bn""Bangla"),
    ("ccp""Chakma"),
    ("en""English"),
    ("es""Spanish"),
    ("fr""French"),
    ("ja""Japanese"),
    ("ru""Russian"),
    ("sr""Serbian"),
    ("th""Thai"),
    ("tr""Turkish"),
];

#[allow(dead_code)]
const BINCODE: [u8; 278] = [
    1100000002000000097114600000006511497,
    98105992000000098110600000006697110103108,
    97300000009999112600000006710497107109972,
    0000000101110700000006911010310810511510420,
    000000101115700000008311297110105115104200,
    00000102114600000007011410111099104200000,
    001069780000000749711297110101115101200000,
    001141177000000082117115115105971102000000,
    01151147000000083101114981059711020000000,
    11610440000000841049710520000000116114700,
    0000084117114107105115104,
];

/// Run this function to print new data to the console.
#[allow(dead_code)]
fn generate() {
    let mut map = LiteMap::new_vec();
    for (lang, name) in DATA.iter() {
        map.try_append(lang, name).ok_or(()).unwrap_err();
    }

    let buf = bincode::serialize(&map).unwrap();
    println!("{buf:?}");
}

#[no_mangle]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
    icu_benchmark_macros::main_setup!();

    // Uncomment the following line to re-generate the binary data.
    // generate();

    let map: LiteMap<&str, &str> = bincode::deserialize(&BINCODE).unwrap();
    assert_eq!(map.get("tr"), Some(&"Turkish"));

    0
}

Messung V0.5 in Prozent
C=90 H=83 G=86

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-06-28) ¤

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