count

Array-specialization of count with default predicate.

  1. size_t count(T[] haystack, T[] needle)
  2. size_t count(T[] haystack, T needle)
    size_t
    count
    (
    T
    )
    (
    scope const T[] haystack
    ,
    scope const T needle
    )
  3. size_t count(T[] haystack)

Examples

// import std.algorithm.searching : count;
assert("".count("_") == 0);
assert("".count(" ") == 0);
assert(" ".count(" ") == 1);
assert("abc_abc".count("a") == 2);
assert("abc_abc".count("abc") == 2);
assert("_a_a_".count("_") == 3);
assert("_aaa_".count("a") == 3);
// assert("".count("") == 0);
// assert("_a_a_".count("") == 5);
assert("".count('_') == 0);
assert("abc_abc".count('a') == 2);
assert("_abc_abc_".count('_') == 3);

Meta