Git Product home page Git Product logo

rs-complete's Introduction

Rust Clippy check Security audit Docs Coverage Status Crates.io

rs-complete

rs-completion is a library to use when you want to implement tab-completion (or similar) in your project.

rs-completion is mainly built for memory efficiency. Completions are stored in binary trees where each node holds a number of characters. The characters in turn link to new nodes. Similar words will thusly share memory.

Visual example

//                          'c' - 'a' - 'v' - 'e'
//                         /
//    root - 'b' - 'a' - 't' - 'm' - 'a' - 'n'
//                               \
//                                'o' - 'b' - 'i' - 'l' - 'e'

This means that a worst case scenario you could have 25^25 nodes in memory where 25 is the size of your alphabet. But this would mean that you are holding every thinkable combination of characters in memory with no regards for consonant or verb rules. If this is what you need then you don't need a library for it.

I can't argue if this solution is fast or efficient. It has worked to solve the problem I intended to solve when I created the library. If you have ideas for extensions or improvements I'm happy to see them.

Example

extern crate rs_completion;
use rs_completion::CompletionTree;

let mut completions = CompletionTree::default();

completions.insert("large bunch of words that bungalow we want to be bundesliga able to complete");
assert_eq!(
    completions.complete("bun"),
    Some(vec!["bunch", "bundesliga", "bungalow"].iter().map(|s| s.to_string()).collect()));

rs-complete's People

Contributors

liquidityc avatar xvxx avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.