Git Product home page Git Product logo

needle's People

Contributors

llogiq avatar peterjoel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

needle's Issues

Please make it possible to compile on rust stable

Gives error

error[E0554]: #![feature] may not be used on the stable release channel

--> C:\Users\pdaniels.cargo\registry\src\github.com-1ecc6299db9ec823\needle-0.1.1\src\lib.rs:2:1
|
2 | #![feature(test)]
| ^^^^^^^^^^^^^^^^^

error: aborting due to previous error

error: Could not compile needle.

Iterator as input

Currently implemented as random access. Allow inputs to be iterators. If possible use a common trait, but a separate API is ok too.

Search over generic alphabets

Searching shouldn't be limited to &[u8]. We should support &[T] (possibly with some constraints), or even use Iterator<T> as input.

Optional parallel searching

Add an optional max_threads attribute to split search out into multiple threads.

This might be complicated (or not really make sense at all) for an iterator- or stream-based API. For finding all matches of a known-length string, it could work though.

find_overlapping_in incorrect?

#[test]
fn needle_genome() {
    let haystack = b"CGGACTCGACAGATGTGAAGAACGACAATGTGAAGACTCGACACGACAGAGTGAAGAGAAGAGGAAACATTGTAA";
    let needle = needle::BoyerMoore::new(&b"GAAGA"[..]);

    assert_eq!(
        vec![16, 31, 52, 57],
        needle.find_overlapping_in(haystack).collect::<Vec<usize>>()
    );
}

This test fails; needle finds [16, 31, 52].

Am I mis-using something or is this just not finding all the matches? The last one isn't even overlapping.

Add methods `contains` and `count`

These can both be optimised better than find, especially for types like String because UTF-8 can be treated as [u8] when you don't need to know the index.

Similarly, an iterator-based API could possibly implement fast search-and-replace on UTF-8 because it wouldn't need to count the characters. This is more complicated though, and might not work, depending offer an improvement on brute-force.

Make the searcher implement Iterator

find_first() is very limited. Instead return an iterator from find(), which will allow the same behaviour as find_first(), using find().next(), but also allow finding all (or some) matches ergonomically.

Custom character matching functions.

Instead of always using ==, there could be opportunities to match on other relations. For example, case-insensitive string matching, or wildcards.

For example, matching a DNA sequence using A C G T nucleotide alphabet, a user might want to match X for unknown/any, or even implement this full list of partially known matches. To do that, they would have to have the ability to redefine "equality".

This might be a bit weird though, as this type of matching function would not be a partial order, since the relation would not be transitive when wild-card elements are involved.

Replace sequence in iterator

It should be possible to make a fast function for replacing subsequences from an iterator. Approximately:

for x in bytes.into_iter().replace_seq(&[1,2,3], &[9,9,9,9,9]) {
   // ....
}

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.