Skip to main content

resq-dsa

Version: v0.1.3 · License: Apache-2.0 · Crate: crates.io · API docs: docs.rs
Crates.io docs.rs License Production-grade data structures and algorithms with zero external dependencies. Designed for no_std environments and embedded systems while remaining ergonomic in standard Rust applications. The crate provides space-efficient probabilistic data structures (Bloom filter, Count-Min sketch), graph algorithms (BFS, Dijkstra, A*), a bounded heap for K-nearest-neighbor tracking, a trie for prefix-based search, and Rabin-Karp rolling-hash string matching.

Module Structure

Feature Flags

Installation

With std (default)

no_std environments

When std is disabled the crate compiles with #![no_std] and relies only on alloc. You must provide a global allocator in your binary.

Data Structures

Bloom Filter

A space-efficient probabilistic set-membership data structure. It can tell you if an element is possibly in the set or definitely not in the set. False positives are possible; false negatives are not. The filter uses k independent FNV-1a hash functions (seeded variants) to set bits in an m-bit array. Optimal values for k and m are computed automatically from the desired capacity and false-positive rate.

Complexity

Where m is the bit-array size and k is the number of hash functions (both derived from capacity and error_rate).

API Reference

Example


Count-Min Sketch

A space-efficient probabilistic data structure for frequency estimation. It may overcount but never undercounts. Estimates are within epsilon * N of the true count with probability 1 - delta, where N is the total count of all increments. Uses depth independent FNV-1a hash functions mapping elements to width columns. The estimated count for a key is the minimum across all rows.

Complexity

Where w = ceil(e / epsilon) (width) and d = ceil(ln(1 / delta)) (depth).

API Reference

Example


Graph (Weighted Directed)

A weighted directed graph with three pathfinding algorithms: breadth-first search (BFS), Dijkstra’s shortest path, and A* with a user-provided heuristic. Node identifiers can be any type that implements Eq + Hash + Clone (and additionally Ord for Dijkstra and A*). Edge weights are u64.

Complexity

* A* worst case matches Dijkstra; with a good heuristic it explores fewer nodes.

API Reference

Examples

A* with a heuristic:

Bounded Heap

A bounded max-heap that retains only the K entries with the smallest distance values. Useful for K-nearest-neighbor search, top-K tracking, and streaming scenarios where you want to keep only the closest results. The root always holds the entry with the largest distance among the retained items. When the heap is full and a new entry has a smaller distance than the root, the root is evicted.

Complexity

Where k is the heap limit.

API Reference

Example

Works with closures:

Trie (Prefix Tree)

A prefix tree for efficient string storage, exact lookup, and prefix-based autocomplete. All operations run in O(m) time where m is the length of the input string. Internally, each node stores a HashMap<char, TrieNode>, making the trie Unicode-aware.

Complexity

Where m is the string length and r is the total length of all matching results.

API Reference

Example


A rolling-hash string matching algorithm that finds all occurrences of a pattern in a text. Uses a polynomial rolling hash with modular arithmetic (base 31, mod 10^9 + 7). The algorithm is Unicode-aware — it operates on char boundaries, so multi-byte characters are handled correctly. Indices in the result are character positions, not byte offsets.

Complexity

Where n is the text length and m is the pattern length (both in chars).

API Reference

Example


Quick Reference

Contributing

  1. Fork the repository and create a feature branch.
  2. Run cargo test to ensure all tests pass.
  3. All new source files must include the Apache-2.0 license header.
  4. Keep binary names consistent with the resq-<name> convention.
  5. Open a pull request against master.

License

Licensed under the Apache License, Version 2.0. See LICENSE for details.

Modules

Click through to each module for the full rustdoc-rendered API surface (types, traits, functions, methods).