View source code
Display the source code in std/algorithm/comparison.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Function std.algorithm.comparison.isSameLength
Checks if the two ranges have the same number of elements. This function is
optimized to always take advantage of the length
member of either range
if it exists.
bool isSameLength(Range1, Range2)
(
Range1 r1,
Range2 r2
)
if (isInputRange!Range1 && isInputRange!Range2 && !isInfinite!Range1 && !isInfinite!Range2);
If both ranges have a length member, this function is Ο(1
). Otherwise,
this function is Ο(min(r1
).
Parameters
Name | Description |
---|---|
r1 | a finite input range |
r2 | a finite input range |
Returns
true
if both ranges have the same length, false
otherwise.
Example
assert(isSameLength([1, 2, 3], [4, 5, 6]));
assert(isSameLength([0.3, 90.4, 23.7, 119.2], [42.6, 23.6, 95.5, 6.3]));
assert(isSameLength("abc", "xyz"));
int[] a;
int[] b;
assert(isSameLength(a, b));
assert(!isSameLength([1, 2, 3], [4, 5]));
assert(!isSameLength([0.3, 90.4, 23.7], [42.6, 23.6, 95.5, 6.3]));
assert(!isSameLength("abcd", "xyz"));
Authors
License
Copyright © 1999-2018 by the D Language Foundation | Page generated by ddox.