rework any/all documentation

This commit is contained in:
monarchdodra 2013-12-19 17:51:26 +01:00
parent 2fdc82741f
commit d31d574882

View file

@ -10658,16 +10658,18 @@ unittest
equal!(canFind!"a < b")([[1, 2, 3], [7, 8, 9]], [2, 3]); equal!(canFind!"a < b")([[1, 2, 3], [7, 8, 9]], [2, 3]);
} }
/** /++
Returns $(D true) if and only if a value $(D v) satisfying the Checks if $(I _any) of the elements verifies $(D pred).
predicate $(D pred) can be found in the forward range $(D +/
range). Performs $(BIGOH r.length) evaluations of $(D pred).
*/
template any(alias pred) template any(alias pred)
{ {
/// ditto /++
Returns $(D true) if and only if $(I _any) value $(D v) found in the
input range $(D range) satisfies the predicate $(D pred).
Performs (at most) $(BIGOH r.length) evaluations of $(D pred).
+/
bool any(Range)(Range range) bool any(Range)(Range range)
if (is(typeof(find!pred(range)))) if (isInputRange!Range && is(typeof(unaryFun!pred(range.front))))
{ {
return !find!pred(range).empty; return !find!pred(range).empty;
} }
@ -10689,15 +10691,18 @@ unittest
assert(any!"a == 2"(a)); assert(any!"a == 2"(a));
} }
/** /++
Returns $(D true) if and only if all values in $(D range) satisfy the Checks if $(I _all) of the elements verifies $(D pred).
predicate $(D pred). Performs $(BIGOH r.length) evaluations of $(D pred). +/
*/
template all(alias pred) template all(alias pred)
{ {
/// ditto /++
bool all(R)(R range) Returns $(D true) if and only if $(I _all) values $(D v) found in the
if (isInputRange!R && is(typeof(unaryFun!pred(range.front)))) input range $(D range) satisfy the predicate $(D pred).
Performs (at most) $(BIGOH r.length) evaluations of $(D pred).
+/
bool all(Range)(Range range)
if (isInputRange!Range && is(typeof(unaryFun!pred(range.front))))
{ {
return find!(not!(unaryFun!pred))(range).empty; return find!(not!(unaryFun!pred))(range).empty;
} }