Prefix tree (ordered map and set) data structure using 100% safe Rust

Related tags

Cryptography pfx
Overview

PFX: A 100% safe, blob-oriented prefix tree

This crate provides a prefix tree map and set data structure, implemented purely in safe Rust.

The API is very similar to std::collections::{HashMap, BTreeMap}, including iteration and an entry API. Iteration proceeds in lexicographical order as determined by the keys.

A notable addition is Prefix search, allowing iteration over all entries whose key starts with a specified prefix.

Example

use pfx::PrefixTreeMap;

fn main() {
    let mut map: PrefixTreeMap<String, u64> = PrefixTreeMap::new();

    map.insert("abc".into(), 123);
    map.insert("def".into(), 456);
    map.insert("defghi".into(), 789);
    
    assert_eq!(map.get("abc").copied(), Some(123));
    assert_eq!(map.get("abcdef").copied(), None);
    assert_eq!(map.get("ab").copied(), None);

    for (key, value) in map.prefix_iter("de") {
        println!("{key} => {value}");
    }
}
You might also like...
Demonstrates Solana data account versioning used in supporting the Solana Cookbook article: Account Data Versioning
Demonstrates Solana data account versioning used in supporting the Solana Cookbook article: Account Data Versioning

versioning-solana This repo demonstrates ONE rudimentary way to upgrade/migrate account data changes with solana program changes. What is data version

A safe implementation of the secure remote password authentication and key-exchange protocol (SRP), SRP6a and legacy are as features available.

Secure Remote Password (SRP 6 / 6a) A safe implementation of the secure remote password authentication and key-exchange protocol (SRP version 6a). Ver

The most advanced Merkle tree library for Rust

rs-merkle rs-merkle is the most advanced Merkle tree library for Rust. Basic features include building a Merkle tree, creation, and verification of Me

The fallen leaves tell a story... of a colorful file tree visualizer for the command-line.
The fallen leaves tell a story... of a colorful file tree visualizer for the command-line.

Erdtree A bLazInGlY fAsT, simplified version of the ancient tree command which displays a colorful depth indented listing of files with their memory s

Bootstrap your merkle tree.

Merkle Generator Bootstrap your merkle tree, in Rust. Table of Contents Features Installation Usage Contributing Features Merkle Tree creation Merkle

Usable, easy and safe pure-Rust crypto

orion About Orion is a cryptography library written in pure Rust. It aims to provide easy and usable crypto while trying to minimize the use of unsafe

Usable, easy and safe pure-Rust crypto

orion About Orion is a cryptography library written in pure Rust. It aims to provide easy and usable crypto while trying to minimize the use of unsafe

A blazingly fast and memory safe password cracker with user interface.
A blazingly fast and memory safe password cracker with user interface.

HashVat A blazingly fast and memory safe password cracker with user interface. HashVat runs with user interface and is capable of cracking the 1.000.0

A blazing fast, type-safe template engine for Rust.

markup.rs A blazing fast, type-safe template engine for Rust. markup.rs is a template engine for Rust powered by procedural macros which parses the te

Owner
Árpád Goretity 
Data Scientist (@UniPD-DM), PhD Student (@PPCU-FITB), PL & Compiler aficionado, public speaker, enthusiastic pianist.
Árpád Goretity 
A sparse merkle tree lib focused on efficient on-chain proofs. Enforces ordering within the merkle tree.

sparse-merkle-tree The merkle tree functions are located in sparse.ak. Currently the supported functionality is: Verifying a new root with an added me

Aiken 5 May 6, 2024
A guide for Mozilla's developers and data scientists to analyze and interpret the data gathered by our data collection systems.

Mozilla Data Documentation This documentation was written to help Mozillians analyze and interpret data collected by our products, such as Firefox and

Mozilla 75 Dec 1, 2022
Retina is a network analysis framework that supports 100+ Gbps traffic analysis on a single server with no specialized hardware.

Retina Retina is a network analysis framework that enables operators and researchers to ask complex questions about high-speed (>100gbE) network links

Stanford Security Research 73 Jun 21, 2023
Safe, fast, small crypto using Rust

THE SOFTWARE IS PROVIDED "AS IS" AND BRIAN SMITH AND THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES

Brian Smith 3k Jan 2, 2023
Lesson 1 - Fundamental structure of smartcontract of near protocol

NEAR CONTRACT dev-1672293046853-49717456344735 pnpm run deploy > [email protected] deploy /Users/vudangquang/Courses/VBI-Courses/rs-contract > cd co

Dang Quang Vu 3 Jan 7, 2023
reth-indexer reads directly from the reth db and indexes the data into a postgres database all decoded with a simple config file and no extra setup alongside exposing a API ready to query the data.

reth-indexer reth-indexer reads directly from the reth db and indexes the data into a postgres database all decoded with a simple config file and no e

Josh Stevens 306 Jul 12, 2023
Rust implementation of the negentropy set-reconcilliation protocol.

Negentropy Description Implementation of the negentropy set-reconciliation protocol. Project structure The project is split up into many crates: negen

Yuki Kishimoto 3 Sep 11, 2023
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Dec 30, 2022
Generates a unique hash/identifier for a system given a set of parameters.

uniqueid ?? Generates a unique hash/identifier for a system given a set of parameters. Example usage use uniqueid; pub fn main() { let data = vec

Checksum 2 Aug 19, 2022