mirror of
https://github.com/dlang/phobos.git
synced 2025-05-01 23:50:31 +03:00
Improve docs for commonPrefix().
This commit is contained in:
parent
1b04b3433a
commit
d5221aeaeb
1 changed files with 16 additions and 4 deletions
|
@ -7544,10 +7544,19 @@ if (isBidirectionalRange!R &&
|
||||||
/**
|
/**
|
||||||
Returns the common prefix of two ranges.
|
Returns the common prefix of two ranges.
|
||||||
|
|
||||||
If the first argument is a string, then the result is a slice of $(D r1) which
|
Params:
|
||||||
contains the characters that both ranges start with. For all other types, the
|
pred = The predicate to use in comparing elements for commonality. Defaults
|
||||||
type of the result is the same as the result of $(D takeExactly(r1, n)), where
|
to equality $(D "a == b").
|
||||||
$(D n) is the number of elements that both ranges start with.
|
|
||||||
|
r1 = A $(XREF2 range, isForwardRange, forward range) of elements.
|
||||||
|
|
||||||
|
r2 = An $(XREF2 range, isInputRange, input range) of elements.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A slice of $(D r1) which contains the characters that both ranges start with,
|
||||||
|
if the first argument is a string; otherwise, the same as the result of
|
||||||
|
$(D takeExactly(r1, n)), where $(D n) is the number of elements in the common
|
||||||
|
prefix of both ranges.
|
||||||
|
|
||||||
See_Also:
|
See_Also:
|
||||||
$(XREF range, takeExactly)
|
$(XREF range, takeExactly)
|
||||||
|
@ -7590,6 +7599,7 @@ if (isForwardRange!R1 && isInputRange!R2 &&
|
||||||
assert(commonPrefix("hello, world", "hello, there") == "hello, ");
|
assert(commonPrefix("hello, world", "hello, there") == "hello, ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ditto
|
||||||
auto commonPrefix(alias pred, R1, R2)(R1 r1, R2 r2)
|
auto commonPrefix(alias pred, R1, R2)(R1 r1, R2 r2)
|
||||||
if (isNarrowString!R1 && isInputRange!R2 &&
|
if (isNarrowString!R1 && isInputRange!R2 &&
|
||||||
is(typeof(binaryFun!pred(r1.front, r2.front))))
|
is(typeof(binaryFun!pred(r1.front, r2.front))))
|
||||||
|
@ -7610,6 +7620,7 @@ if (isNarrowString!R1 && isInputRange!R2 &&
|
||||||
return result[0 .. i];
|
return result[0 .. i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ditto
|
||||||
auto commonPrefix(R1, R2)(R1 r1, R2 r2)
|
auto commonPrefix(R1, R2)(R1 r1, R2 r2)
|
||||||
if (isNarrowString!R1 && isInputRange!R2 && !isNarrowString!R2 &&
|
if (isNarrowString!R1 && isInputRange!R2 && !isNarrowString!R2 &&
|
||||||
is(typeof(r1.front == r2.front)))
|
is(typeof(r1.front == r2.front)))
|
||||||
|
@ -7617,6 +7628,7 @@ if (isNarrowString!R1 && isInputRange!R2 && !isNarrowString!R2 &&
|
||||||
return commonPrefix!"a == b"(r1, r2);
|
return commonPrefix!"a == b"(r1, r2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ditto
|
||||||
auto commonPrefix(R1, R2)(R1 r1, R2 r2)
|
auto commonPrefix(R1, R2)(R1 r1, R2 r2)
|
||||||
if (isNarrowString!R1 && isNarrowString!R2)
|
if (isNarrowString!R1 && isNarrowString!R2)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue