Sign in

    trie

    A simple implementation of a Trie data structure

    data structures
    utils
    trie
    Download zip
    Author
    Version
    0.2.10
    License
    Apache-2.0
    Last updated
    8 months ago
    Downloads
    107K

    No dependencies

    #Trie

    A trie, also known as a prefix tree, is a tree-like data structure that stores a collection of strings. This implementation provides the basic functionality of a trie, including inserting strings and searching for strings.

    #Usage

    ///|
    using @trie {type Trie}

    ///|
    test {
    let trie = Trie::of([("--search", "search"), ("--switch", "switch")])
    inspect(trie.lookup("--search"), content="Some(\"search\")")
    let trie = trie.add("-s", "s")
    inspect(trie.lookup("-s"), content="Some(\"s\")")
    inspect(trie.lookup("--switch"), content="Some(\"switch\")")
    }

    Trie

    #alias(T)
    type Trie[A]

    Trie::add

    fn[A] Trie::add(self : Trie[A], path : String, value : A) -> Trie[A]

    Trie::empty

    fn[A] Trie::empty() -> Trie[A]

    Trie::from_array

    fn[A] Trie::from_array(data : Array[(String, A)]) -> Trie[A]

    Create a trie from array.

    Trie::insert

    #deprecated("use `add` instead")
    fn[A] Trie::insert(self : Trie[A], path : String, value : A) -> Trie[A]

    Trie::lookup

    fn[A] Trie::lookup(self : Trie[A], path : String) -> A?

    Trie::of

    fn[A] Trie::of(data : FixedArray[(String, A)]) -> Trie[A]

    Create a trie from FixedArray

    empty

    #deprecated("Use Trie::empty instead")
    fn[A] empty() -> Trie[A]

    Source Files

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io