trie-simple: Simple Map-based Trie

[ bsd3, data-structures, library ] [ Propose Tags ] [ Report a vulnerability ]

A trie data structure TMap c v, to hold a mapping from list of characters ([c]) to something. In other words, a data structure isomorphic to Map [c] v. It is more efficient to query compared to Map. Also, it supports extra operations like prefix matching. This package contains TSet c too, which is isomorphic to Set [c].


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.4.1.1, 0.4.2, 0.4.3
Change log CHANGELOG.md
Dependencies base (>=4.14 && <4.22), containers (>=0.5.7.1 && <0.8), deepseq (>=1.4.2.0 && <1.6), hashable (>=1.3 && <1.6), indexed-traversable (>=0.1.1 && <0.2), matchable (>=0.1.2 && <0.2), mtl (>=2.2.1 && <2.4), semialign (>=1.3 && <1.4), these (>=1 && <2), witherable (>=0.4 && <0.6) [details]
Tested with ghc ==9.2.8, ghc ==9.4.8, ghc ==9.6.6, ghc ==9.8.2, ghc ==9.10.1
License BSD-3-Clause
Copyright Koji Miyazato
Author Koji Miyazato
Maintainer viercc@gmail.com
Category Data Structures
Source repo head: git clone https://github.com/viercc/trie-simple -b master
Uploaded by viercc at 2024-12-14T06:07:38Z
Distributions LTSHaskell:0.4.2, NixOS:0.4.2, Stackage:0.4.2
Reverse Dependencies 1 direct, 1 indirect [details]
Downloads 1978 total (25 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2024-12-14 [all 1 reports]

Readme for trie-simple-0.4.3

[back to package description]

trie-simple

Trie data structure TMap to hold mapping from list of characters to something, i.e. isomorphic to Map [c] v. This package also contains TSet, which is isomorphic to Set of lists of characters.

This package implements these structures using Map from containers package, and require the character type to be only Ord.

Advantages of using this package over Map or Set are:

  • 2x Faster lookup (member) operation
  • Retrieving subset of map or set with given prefix
  • append, prefixes, and suffixes support
  • Can be more memory-efficient (but not always; needs benchmark anyway).

Benchmarks

Benchmarks compared against plain Map and Set.

benchmark chart for TMap

benchmark chart for TSet

Each of these benchmarks has two sets of point and errorbars, representing two datasets they are run against.

Notice: the datasets are not included in the tarball distributed from Hackage. To run the benchmark, either get the entire repository from the source repository (GitHub) or modify the benchmark program and supply any dataset of your choice.

About License

LICENSE tells the licence of this project, EXCEPT one file for benchmark input data. See ABOUT for that file.

If you install trie-simple from Hackage, that input data is not included in the distributed files.