contains

Performs a linear scan of haystack from [0 .. haystack.length$(RP), returning true if an element matching needle is found. Comparisons will be performed using the supplied predicate or '==' if none is supplied.

Parameters

haystack Buffer!(T)

The array to search.

needle T[]

The pattern to search for.

pred Pred

The evaluation predicate, which should return true if e1 is equal to e2 and false if not. This predicate may be any callable type.

Return Value

Type: equals_t

True if an element equivalent to needle is found, false if not.

Examples

test( contains("abc", 'a'));
test(!contains("abc", 'd'));
test( contains("abc", "a"));
test(!contains("abc", "d"));
auto buffer = createBuffer("abc");
test( contains(buffer, 'a'));
test(!contains(buffer, 'd'));
auto buffer = createBuffer("abc");
test( contains(buffer, "a"));
test(!contains(buffer, "d"));

Meta