boyerMooreFinder

Sets up Boyer-Moore matching for use with find below. By default, elements are compared for equality.

BoyerMooreFinder allocates GC memory.

  1. struct BoyerMooreFinder(alias pred, Range)
  2. BoyerMooreFinder!(binaryFun!(pred), Range) boyerMooreFinder(Range needle)
    BoyerMooreFinder!(binaryFun!(pred), Range)
    boyerMooreFinder
    (
    alias pred = "a == b"
    Range
    )
    (
    Range needle
    )
    if (
    () ||
    )

Parameters

pred

Predicate used to compare elements.

needle Range

A random-access range with length and slicing.

Return Value

Type: BoyerMooreFinder!(binaryFun!(pred), Range)

An instance of BoyerMooreFinder that can be used with find() to invoke the Boyer-Moore matching algorithm for finding of needle in a given haystack.

Examples

auto bmFinder = boyerMooreFinder("TG");

string r = "TAGTGCCTGA";
// search for the first match in the haystack r
r = bmFinder.beFound(r);
assert(r == "TGCCTGA");

// continue search in haystack
r = bmFinder.beFound(r[2 .. $]);
assert(r == "TGA");

Meta

Suggestion Box / Bug Report