canFind

Array-specialization of count with default predicate.

TODO: Add optimized implementation for needles with length >= largeNeedleLength with no repeat of elements.

TODO: reuse return haystack.indexOf(needle) != -1 in both overloads

  1. bool canFind(T[] haystack, T[] needle)
  2. bool canFind(T[] haystack, T needle)
    @trusted
    bool
    canFind
    (
    T
    )
    (
    scope const T[] haystack
    ,
    scope const T needle
    )
  3. bool startsWith(T[] haystack, T[] needle)
  4. bool startsWith(T[] haystack, T needle)

Examples

assert(!"".canFind("_"));
assert(!"a".canFind("_"));
assert("a".canFind("a"));
assert(!"a".canFind("ab"));
assert("ab".canFind("a"));
assert("ab".canFind("b"));
assert("ab".canFind("ab"));
assert(!"a".canFind("ab"));
assert(!"b".canFind("ab"));
assert(!"".canFind('_'));
assert(!"a".canFind('_'));
assert("a".canFind('a'));
assert("a".canFind('a'));
assert("ab".canFind('a'));
assert("ab".canFind('b'));

Meta