<script type="text/javascript">inhibitQuickIndex = 1</script> $(BOOKTABLE , $(TR $(TH Category) $(TH Functions) ) $(TR $(TDNW Searching) $(TD $(MYREF balancedParens) $(MYREF boyerMooreFinder) $(MYREF canFind) $(MYREF count) $(MYREF countUntil) $(MYREF endsWith) $(MYREF commonPrefix) $(MYREF find) $(MYREF findAdjacent) $(MYREF findAmong) $(MYREF findSkip) $(MYREF findSplit) $(MYREF findSplitAfter) $(MYREF findSplitBefore) $(MYREF indexOf) $(MYREF minCount) $(MYREF minPos) $(MYREF mismatch) $(MYREF skipOver) $(MYREF startsWith) $(MYREF until) ) ) $(TR $(TDNW Comparison) $(TD $(MYREF cmp) $(MYREF equal) $(MYREF levenshteinDistance) $(MYREF levenshteinDistanceAndPath) $(MYREF max) $(MYREF min) $(MYREF mismatch) ) ) $(TR $(TDNW Iteration) $(TD $(MYREF filter) $(MYREF filterBidirectional) $(MYREF group) $(MYREF joiner) $(MYREF map) $(MYREF reduce) $(MYREF splitter) $(MYREF uniq) ) ) $(TR $(TDNW Sorting) $(TD $(MYREF completeSort) $(MYREF isPartitioned) $(MYREF isSorted) $(MYREF makeIndex) $(MYREF partialSort) $(MYREF partition) $(MYREF partition3) $(MYREF schwartzSort) $(MYREF sort) $(MYREF topN) $(MYREF topNCopy) ) ) $(TR $(TDNW Set operations) $(TD $(MYREF largestPartialIntersection) $(MYREF largestPartialIntersectionWeighted) $(MYREF nWayUnion) $(MYREF setDifference) $(MYREF setIntersection) $(MYREF setSymmetricDifference) $(MYREF setUnion) ) ) $(TR $(TDNW Mutation) $(TD $(MYREF bringToFront) $(MYREF copy) $(MYREF fill) $(MYREF initializeAll) $(MYREF move) $(MYREF moveAll) $(MYREF moveSome) $(MYREF remove) $(MYREF reverse) $(MYREF swap) $(MYREF swapRanges) $(MYREF uninitializedFill) )) ) Implements algorithms oriented mainly towards processing of sequences. Some functions are semantic equivalents or supersets of those found in the $(D $(LESS)_algorithm$(GREATER)) header in $(WEB sgi.com/tech/stl/, Alexander Stepanov's Standard Template Library) for C++. Many functions in this module are parameterized with a function or a $(GLOSSARY predicate). The predicate may be passed either as a function name, a delegate name, a $(GLOSSARY functor) name, or a compile-time string. The string may consist of $(B any) legal D expression that uses the symbol $(D a) (for unary functions) or the symbols $(D a) and $(D b) (for binary functions). These names will NOT interfere with other homonym symbols in user code because they are evaluated in a different context. The default for all binary comparison predicates is $(D "a == b") for unordered operations and $(D "a < b") for ordered operations. Example: ---- int[] a = ...; static bool greater(int a, int b) { return a > b; } sort!(greater)(a); // predicate as alias sort!("a > b")(a); // predicate as string // (no ambiguity with array name) sort(a); // no predicate, "a < b" is implicit ---- $(BOOKTABLE Cheat Sheet, $(TR $(TH Function Name) $(TH Description) ) $(LEADINGROW Searching ) $(TR $(TDNW $(LREF balancedParens)) $(TD $(D balancedParens("((1 + 1) / 2)")) returns $(D true) because the string has balanced parentheses.) ) $(TR $(TDNW $(LREF boyerMooreFinder)) $(TD $(D find("hello world", boyerMooreFinder("or"))) returns $(D "orld") using the $(LUCKY Boyer-Moore _algorithm).) ) $(TR $(TDNW $(LREF canFind)) $(TD $(D canFind("hello world", "or")) returns $(D true).) ) $(TR $(TDNW $(LREF count)) $(TD Counts elements that are equal to a specified value or satisfy a predicate. $(D count([1, 2, 1], 1)) returns $(D 2) and $(D count!"a < 0"([1, -3, 0])) returns $(D 1).) ) $(TR $(TDNW $(LREF countUntil)) $(TD $(D countUntil(a, b)) returns the number of steps taken in $(D a) to reach $(D b); for example, $(D countUntil("hello!", "o")) returns $(D 4).) ) $(TR $(TDNW $(LREF endsWith)) $(TD $(D endsWith("rocks", "ks")) returns $(D true).) ) $(TR $(TD $(LREF find)) $(TD $(D find("hello world", "or")) returns $(D "orld") using linear search. (For binary search refer to $(XREF range,sortedRange).)) ) $(TR $(TDNW $(LREF findAdjacent)) $(TD $(D findAdjacent([1, 2, 3, 3, 4])) returns the subrange starting with two equal adjacent elements, i.e. $(D [3, 3, 4]).) ) $(TR $(TDNW $(LREF findAmong)) $(TD $(D findAmong("abcd", "qcx")) returns $(D "cd") because $(D 'c') is among $(D "qcx").) ) $(TR $(TDNW $(LREF findSkip)) $(TD If $(D a = "abcde"), then $(D findSkip(a, "x")) returns $(D false) and leaves $(D a) unchanged, whereas $(D findSkip(a, 'c')) advances $(D a) to $(D "cde") and returns $(D true).) ) $(TR $(TDNW $(LREF findSplit)) $(TD $(D findSplit("abcdefg", "de")) returns the three ranges $(D "abc"), $(D "de"), and $(D "fg").) ) $(TR $(TDNW $(LREF findSplitAfter)) $(TD $(D findSplitAfter("abcdefg", "de")) returns the two ranges $(D "abcde") and $(D "fg").) ) $(TR $(TDNW $(LREF findSplitBefore)) $(TD $(D findSplitBefore("abcdefg", "de")) returns the two ranges $(D "abc") and $(D "defg").) ) $(TR $(TDNW $(LREF minCount)) $(TD $(D minCount([2, 1, 1, 4, 1])) returns $(D tuple(1, 3)).) ) $(TR $(TDNW $(LREF minPos)) $(TD $(D minPos([2, 3, 1, 3, 4, 1])) returns the subrange $(D [1, 3, 4, 1]), i.e., positions the range at the first occurrence of its minimal element.) ) $(TR $(TDNW $(LREF skipOver)) $(TD Assume $(D a = "blah"). Then $(D skipOver(a, "bi")) leaves $(D a) unchanged and returns $(D false), whereas $(D skipOver(a, "bl")) advances $(D a) to refer to $(D "ah") and returns $(D true).) ) $(TR $(TDNW $(LREF startsWith)) $(TD $(D startsWith("hello, world", "hello")) returns $(D true).) ) $(TR $(TDNW $(LREF until)) $(TD Lazily iterates a range until a specific value is found.) ) $(LEADINGROW Comparison ) $(TR $(TDNW $(LREF cmp)) $(TD $(D cmp("abc", "abcd")) is $(D -1), $(D cmp("abc", aba")) is $(D 1), and $(D cmp("abc", "abc")) is $(D 0).) ) $(TR $(TDNW $(LREF equal)) $(TD Compares ranges for element-by-element equality, e.g. $(D equal([1, 2, 3], [1.0, 2.0, 3.0])) returns $(D true).) ) $(TR $(TDNW $(LREF levenshteinDistance)) $(TD $(D levenshteinDistance("kitten", "sitting")) returns $(D 3) by using the $(LUCKY Levenshtein distance _algorithm).) ) $(TR $(TDNW $(LREF levenshteinDistanceAndPath)) $(TD $(D levenshteinDistanceAndPath("kitten", "sitting")) returns $(D tuple(3, "snnnsni")) by using the $(LUCKY Levenshtein distance _algorithm).) ) $(TR $(TDNW $(LREF max)) $(TD $(D max(3, 4, 2)) returns $(D 4).) ) $(TR $(TDNW $(LREF min)) $(TD $(D min(3, 4, 2)) returns $(D 2).) ) $(TR $(TDNW $(LREF mismatch)) $(TD $(D mismatch("oh hi", "ohayo")) returns $(D tuple(" hi", "ayo")).) ) $(LEADINGROW Iteration ) $(TR $(TDNW $(LREF filter)) $(TD $(D filter!"a > 0"([1, -1, 2, 0, -3])) iterates over elements $(D 1), $(D 2), and $(D 0).) ) $(TR $(TDNW $(LREF filterBidirectional)) $(TD Similar to $(D filter), but also provides $(D back) and $(D popBack) at a small increase in cost.) ) $(TR $(TDNW $(LREF group)) $(TD $(D group([5, 2, 2, 3, 3])) returns a range containing the tuples $(D tuple(5, 1)), $(D tuple(2, 2)), and $(D tuple(3, 2)).) ) $(TR $(TDNW $(LREF joiner)) $(TD $(D joiner(["hello", "world!"], ";")) returns a range that iterates over the characters $(D "hello; world!"). No new string is created - the existing inputs are iterated.) ) $(TR $(TDNW $(LREF map)) $(TD $(D map!"2 * a"([1, 2, 3])) lazily returns a range with the numbers $(D 2), $(D 4), $(D 6).) ) $(TR $(TDNW $(LREF reduce)) $(TD $(D reduce!"a + b"([1, 2, 3, 4])) returns $(D 10).) ) $(TR $(TDNW $(LREF splitter)) $(TD Lazily splits a range by a separator.) ) $(TR $(TDNW $(LREF uniq)) $(TD Iterates over the unique elements in a range, which is assumed sorted.) ) $(LEADINGROW Sorting ) $(TR $(TDNW $(LREF completeSort)) $(TD If $(D a = [10, 20, 30]) and $(D b = [40, 6, 15]), then $(D completeSort(a, b)) leaves $(D a = [6, 10, 15]) and $(D b = [20, 30, 40]). The range $(D a) must be sorted prior to the call, and as a result the combination $(D $(XREF range,chain)(a, b)) is sorted.) ) $(TR $(TDNW $(LREF isPartitioned)) $(TD $(D isPartitioned!"a < 0"([-1, -2, 1, 0, 2])) returns $(D true) because the predicate is $(D true) for a portion of the range and $(D false) afterwards.) ) $(TR $(TDNW $(LREF isSorted)) $(TD $(D isSorted([1, 1, 2, 3])) returns $(D true).) ) $(TR $(TDNW $(LREF makeIndex)) $(TD Creates a separate index for a range.) ) $(TR $(TDNW $(LREF partialSort)) $(TD If $(D a = [5, 4, 3, 2, 1]), then $(D partialSort(a, 3)) leaves $(D a[0 .. 3] = [1, 2, 3]). The other elements of $(D a) are left in an unspecified order.) ) $(TR $(TDNW $(LREF partition)) $(TD Partitions a range according to a predicate.) ) $(TR $(TDNW $(LREF schwartzSort)) $(TD Sorts with the help of the $(LUCKY Schwartzian transform).) ) $(TR $(TDNW $(LREF sort)) $(TD Sorts.) ) $(TR $(TDNW $(LREF topN)) $(TD Separates the top elements in a range.) ) $(TR $(TDNW $(LREF topNCopy)) $(TD Copies out the top elements of a range.) ) $(LEADINGROW Set operations ) $(TR $(TDNW $(LREF largestPartialIntersection)) $(TD Copies out the values that occur most frequently in a range of ranges.) ) $(TR $(TDNW $(LREF largestPartialIntersectionWeighted)) $(TD Copies out the values that occur most frequently (multiplied by per-value weights) in a range of ranges.) ) $(TR $(TDNW $(LREF nWayUnion)) $(TD Computes the union of a set of sets implemented as a range of sorted ranges.) ) $(TR $(TDNW $(LREF setDifference)) $(TD Lazily computes the set difference of two or more sorted ranges.) ) $(TR $(TDNW $(LREF setIntersection)) $(TD Lazily computes the set difference of two or more sorted ranges.) ) $(TR $(TDNW $(LREF setSymmetricDifference)) $(TD Lazily computes the symmetric set difference of two or more sorted ranges.) ) $(TR $(TDNW $(LREF setUnion)) $(TD Lazily computes the set union of two or more sorted ranges.) ) $(LEADINGROW Mutation ) $(TR $(TDNW $(LREF bringToFront)) $(TD If $(D a = [1, 2, 3]) and $(D b = [4, 5, 6, 7]), $(D bringToFront(a, b)) leaves $(D a = [4, 5, 6]) and $(D b = [7, 1, 2, 3]).) ) $(TR $(TDNW $(LREF copy)) $(TD Copies a range to another. If $(D a = [1, 2, 3]) and $(D b = new int[5]), then $(D copy(a, b)) leaves $(D b = [1, 2, 3, 0, 0]) and returns $(D b[3 .. $]).) ) $(TR $(TDNW $(LREF fill)) $(TD Fills a range with a pattern, e.g., if $(D a = new int[3]), then $(D fill(a, 4)) leaves $(D a = [4, 4, 4]) and $(D fill(a, [3, 4])) leaves $(D a = [3, 4, 3]).) ) $(TR $(TDNW $(LREF initializeAll)) $(TD If $(D a = [1.2, 3.4]), then $(D initializeAll(a)) leaves $(D a = [double.init, double.init]).) ) $(TR $(TDNW $(LREF move)) $(TD $(D move(a, b)) moves $(D a) into $(D b). $(D move(a)) reads $(D a) destructively.) ) $(TR $(TDNW $(LREF moveAll)) $(TD Moves all elements from one range to another.) ) $(TR $(TDNW $(LREF moveSome)) $(TD Moves as many elements as possible from one range to another.) ) $(TR $(TDNW $(LREF reverse)) $(TD If $(D a = [1, 2, 3]), $(D reverse(a)) changes it to $(D [3, 2, 1]).) ) $(TR $(TDNW $(LREF swap)) $(TD Swaps two values.) ) $(TR $(TDNW $(LREF swapRanges)) $(TD Swaps all elements of two ranges.) ) $(TR $(TDNW $(LREF uninitializedFill)) $(TD Fills a range (assumed uninitialized) with a value.) ) ) Macros: WIKI = Phobos/StdAlgorithm MYREF = <font face='Consolas, "Bitstream Vera Sans Mono", "Andale Mono", Monaco, "DejaVu Sans Mono", "Lucida Console", monospace'><a href="#$1">$1</a> </font> Copyright: Andrei Alexandrescu 2008-. License: $(WEB boost.org/LICENSE_1_0.txt, Boost License 1.0). Authors: $(WEB erdani.com, Andrei Alexandrescu) Source: $(PHOBOSSRC std/_algorithm.d)

- map(fun...) if (fun.length >= 1)
Implements the homonym function (also known as $(D transform)) present in many languages of functional flavor. The call $(D map!(fun)(range)) returns a range of which elements are obtained by applying $(D fun(x)) left to right for all $(D x) in $(D range). The original ranges are not changed. Evaluation is done lazily. The range returned by $(D map) caches the last value such that evaluating $(D front) multiple times does not result in multiple calls to $(D fun).

- reduce(fun...) if (fun.length >= 1)
Implements the homonym function (also known as $(D accumulate), $(D compress), $(D inject), or $(D foldl)) present in various programming languages of functional flavor. The call $(D reduce!(fun)(seed, range)) first assigns $(D seed) to an internal variable $(D result), also called the accumulator. Then, for each element $(D x) in $(D range), $(D result = fun(result, x)) gets evaluated. Finally, $(D result) is returned. The one-argument version $(D reduce!(fun)(range)) works similarly, but it uses the first element of the range as the seed (the range must be non-empty).

- fill(Range,Value) if (isInputRange!(Range) && is(typeof(range.front = filler)))
Fills a range with a value.

- fill(Range1,Range2) if (isInputRange!(Range1) && isForwardRange!(Range2) && is(typeof(Range1.init.front = Range2.init.front)))
Fills $(D range) with a pattern copied from $(D filler). The length of $(D range) does not have to be a multiple of the length of $(D filler). If $(D filler) is empty, an exception is thrown.

- uninitializedFill(Range,Value) if (isForwardRange!(Range) && is(typeof(range.front = filler)))
Fills a range with a value. Assumes that the range does not currently contain meaningful content. This is of interest for structs that define copy constructors (for all other types, fill and uninitializedFill are equivalent).

- initializeAll(Range) if (isForwardRange!(Range) && is(typeof(range.front = range.front)))
Initializes all elements of a range with their $(D .init) value. Assumes that the range does not currently contain meaningful content.

- filter(alias pred) if (is(typeof(unaryFun!(pred))))
Implements the homonym function present in various programming languages of functional flavor. The call $(D filter!(fun)(range)) returns a new range only containing elements $(D x) in $(D r) for which $(D predicate(x)) is $(D true).

- filterBidirectional(alias pred)
Similar to $(D filter), except it defines a bidirectional range. There is a speed disadvantage - the constructor spends time finding the last element in the range that satisfies the filtering condition (in addition to finding the first one). The advantage is that the filtered range can be spanned from both directions. Also, $(XREF range, retro) can be applied against the filtered range.

- move(T)
Moves $(D source) into $(D target) via a destructive copy. Specifically: $(UL $(LI If $(D hasAliasing!T) is true (see $(XREF traits, hasAliasing)), then the representation of $(D source) is bitwise copied into $(D target) and then $(D source = T.init) is evaluated.) $(LI Otherwise, $(D target = source) is evaluated.)) See also $(XREF exception, pointsTo).

- move(T)
Moves $(D source) into $(D target) via a destructive copy. Specifically: $(UL $(LI If $(D hasAliasing!T) is true (see $(XREF traits, hasAliasing)), then the representation of $(D source) is bitwise copied into $(D target) and then $(D source = T.init) is evaluated.) $(LI Otherwise, $(D target = source) is evaluated.)) See also $(XREF exception, pointsTo).

- moveAll(Range1,Range2) if (isInputRange!(Range1) && isInputRange!(Range2) && is(typeof(move(src.front,tgt.front))))
For each element $(D a) in $(D src) and each element $(D b) in $(D tgt) in lockstep in increasing order, calls $(D move(a, b)). Returns the leftover portion of $(D tgt). Throws an exeption if there is not enough room in $(D tgt) to acommodate all of $(D src).

- moveSome(Range1,Range2) if (isInputRange!(Range1) && isInputRange!(Range2) && is(typeof(move(src.front,tgt.front))))
For each element $(D a) in $(D src) and each element $(D b) in $(D tgt) in lockstep in increasing order, calls $(D move(a, b)). Stops when either $(D src) or $(D tgt) have been exhausted. Returns the leftover portions of the two ranges.

- swap(T) if (isMutable!(T) && !is(typeof(T.init.proxySwap(T.init))))
Swaps $(D lhs) and $(D rhs). See also $(XREF exception, pointsTo).

- swap(T) if (is(typeof(T.init.proxySwap(T.init))))
- swapFront(R1,R2) if (isInputRange!(R1) && isInputRange!(R2))
- splitter(Range,Separator) if (is(typeof(ElementType!(Range).init == Separator.init)) && (hasSlicing!(Range) || isNarrowString!(Range)))
Splits a range using an element as a separator. This can be used with any range type, but is most popular with string types.

- splitter(Range,Separator) if (is(typeof(Range.init.front == Separator.init.front) : bool))
Splits a range using another range as a separator. This can be used with any range type, but is most popular with string types.

- splitter(alias isTerminator,Range) if (is(typeof(unaryFun!(isTerminator)(ElementType!(Range).init))))
- splitter(Range) if (isSomeString!(Range))
- joiner(RoR,Separator) if (isInputRange!(RoR) && isInputRange!(ElementType!(RoR)) && isForwardRange!(Separator) && is(ElementType!(Separator) : ElementType!(ElementType!(RoR))))
Lazily joins a range of ranges with a separator. The separator itself is a range. If you do not provide a separator, then the ranges are joined directly without anything in between them.

- joiner(RoR) if (isInputRange!(RoR) && isInputRange!(ElementType!(RoR)))
Lazily joins a range of ranges with a separator. The separator itself is a range. If you do not provide a separator, then the ranges are joined directly without anything in between them.

- uniq(alias pred = "a == b",Range) if (isInputRange!(Range) && is(typeof(binaryFun!(pred)(r.front,r.front)) == bool))
Iterates unique consecutive elements of the given range (functionality akin to the $(WEB wikipedia.org/wiki/_Uniq, _uniq) system utility). Equivalence of elements is assessed by using the predicate $(D pred), by default $(D "a == b"). If the given range is bidirectional, $(D uniq) also yields a bidirectional range.

- Group(alias pred,R) if (isInputRange!(R))
Similarly to $(D uniq), $(D group) iterates unique consecutive elements of the given range. The element type is $(D Tuple!(ElementType!R, uint)) because it includes the count of equivalent elements seen. Equivalence of elements is assessed by using the predicate $(D pred), by default $(D "a == b").

- group(alias pred = "a == b",Range)
Similarly to $(D uniq), $(D group) iterates unique consecutive elements of the given range. The element type is $(D Tuple!(ElementType!R, uint)) because it includes the count of equivalent elements seen. Equivalence of elements is assessed by using the predicate $(D pred), by default $(D "a == b").

- find(alias pred = "a == b",R,E) if (isInputRange!(R) && is(typeof(binaryFun!(pred)(haystack.front,needle)) : bool))
Finds an individual element in an input range. Elements of $(D haystack) are compared with $(D needle) by using predicate $(D pred). Performs $(BIGOH walkLength(haystack)) evaluations of $(D pred). See also $(WEB sgi.com/tech/stl/_find.html, STL's _find).

- find(alias pred = "a == b",R1,R2) if (isForwardRange!(R1) && isForwardRange!(R2) && is(typeof(binaryFun!(pred)(haystack.front,needle.front)) : bool) && !isRandomAccessRange!(R1))
Finds a forward range in another. Elements are compared for equality. Performs $(BIGOH walkLength(haystack) * walkLength(needle)) comparisons in the worst case. Specializations taking advantage of bidirectional or random access (where present) may accelerate search depending on the statistics of the two ranges' content.

- find(alias pred = "a == b",R1,R2) if (isRandomAccessRange!(R1) && isBidirectionalRange!(R2) && is(typeof(binaryFun!(pred)(haystack.front,needle.front)) : bool))
- find(alias pred = "a == b",R1,R2) if (isRandomAccessRange!(R1) && isForwardRange!(R2) && !isBidirectionalRange!(R2) && is(typeof(binaryFun!(pred)(haystack.front,needle.front)) : bool))
- simpleMindedFind(alias pred,R1,R2)
- find(alias pred = "a == b",Range,Ranges...) if (Ranges.length > 1 && allSatisfy!(isForwardRange,Ranges))
Finds two or more $(D needles) into a $(D haystack). The predicate $(D pred) is used throughout to compare elements. By default, elements are compared for equality.

- BoyerMooreFinder(alias pred,Range)
- boyerMooreFinder(alias pred = "a == b",Range) if (isRandomAccessRange!(Range) || isSomeString!(Range))
- find(Range1,alias pred,Range2)
- find(alias pred,Range) if (isInputRange!(Range))
Advances the input range $(D haystack) by calling $(D haystack.popFront) until either $(D pred(haystack.front)), or $(D haystack.empty). Performs $(BIGOH haystack.length) evaluations of $(D pred). See also $(WEB sgi.com/tech/stl/find_if.html, STL's find_if).

- findSkip(alias pred = "a == b",R1,R2) if (isForwardRange!(R1) && isForwardRange!(R2) && is(typeof(binaryFun!(pred)(haystack.front,needle.front))))
If $(D needle) occurs in $(D haystack), positions $(D haystack) right after the first occurrence of $(D needle) and returns $(D true). Otherwise, leaves $(D haystack) as is and returns $(D false).

- findSplit(alias pred = "a == b",R1,R2) if (isForwardRange!(R1) && isForwardRange!(R2))
These functions find the first occurrence of $(D needle) in $(D haystack) and then split $(D haystack) as follows.

- findSplitBefore(alias pred = "a == b",R1,R2) if (isForwardRange!(R1) && isForwardRange!(R2))
These functions find the first occurrence of $(D needle) in $(D haystack) and then split $(D haystack) as follows.

- findSplitAfter(alias pred = "a == b",R1,R2) if (isForwardRange!(R1) && isForwardRange!(R2))
These functions find the first occurrence of $(D needle) in $(D haystack) and then split $(D haystack) as follows.

- countUntil(alias pred = "a == b",R,N) if (is(typeof(startsWith!(pred)(haystack,needle))))
Returns the number of elements which must be popped from the front of $(D haystack) before reaching an element for which $(D startsWith!pred(haystack, needle)) is $(D true). If $(D startsWith!pred(haystack, needle)) is not $(D true) for any element in $(D haystack), then -1 is returned.

- countUntil(alias pred,R) if (isForwardRange!(R) && is(typeof(unaryFun!(pred)(haystack.front)) == bool))
Returns the number of elements which must be popped from $(D haystack) before $(D pred(haystack.front)) is $(D true).

- indexOf(alias pred = "a == b",R1,R2) if (is(typeof(startsWith!(pred)(haystack,needle))))
$(RED Deprecated. It will be removed in January 2013. Please use $(LREF countUntil) instead.)

- OpenRight
Interval option specifier for $(D until) (below) and others.

- Until(alias pred,Range,Sentinel) if (isInputRange!(Range))
Lazily iterates $(D range) until value $(D sentinel) is found, at which point it stops.

- until(alias pred = "a == b",Range,Sentinel) if (!is(Sentinel == OpenRight))
Lazily iterates $(D range) until value $(D sentinel) is found, at which point it stops.

- until(alias pred,Range)
Lazily iterates $(D range) until value $(D sentinel) is found, at which point it stops.

- startsWith(alias pred = "a == b",Range,Ranges...) if (isInputRange!(Range) && Ranges.length > 1 && is(typeof(.startsWith!(pred)(doesThisStart,withOneOfThese[0])) : bool) && is(typeof(.startsWith!(pred)(doesThisStart,withOneOfThese[1..__dollar])) : uint))
If the range $(D doesThisStart) starts with $(I any) of the $(D withOneOfThese) ranges or elements, returns 1 if it starts with $(D withOneOfThese[0]), 2 if it starts with $(D withOneOfThese[1]), and so on. If none match, returns 0. In the case where $(D doesThisStart) starts with multiple of the ranges or elements in $(D withOneOfThese), then the shortest one matches (if there are two which match which are of the same length (e.g. $(D "a") and $(D 'a')), then the left-most of them in the argument list matches).

- startsWith(alias pred = "a == b",R1,R2) if (isInputRange!(R1) && isInputRange!(R2) && is(typeof(binaryFun!(pred)(doesThisStart.front,withThis.front)) : bool))
If the range $(D doesThisStart) starts with $(I any) of the $(D withOneOfThese) ranges or elements, returns 1 if it starts with $(D withOneOfThese[0]), 2 if it starts with $(D withOneOfThese[1]), and so on. If none match, returns 0. In the case where $(D doesThisStart) starts with multiple of the ranges or elements in $(D withOneOfThese), then the shortest one matches (if there are two which match which are of the same length (e.g. $(D "a") and $(D 'a')), then the left-most of them in the argument list matches).

- startsWith(alias pred = "a == b",R,E) if (isInputRange!(R) && is(typeof(binaryFun!(pred)(doesThisStart.front,withThis)) : bool))
If the range $(D doesThisStart) starts with $(I any) of the $(D withOneOfThese) ranges or elements, returns 1 if it starts with $(D withOneOfThese[0]), 2 if it starts with $(D withOneOfThese[1]), and so on. If none match, returns 0. In the case where $(D doesThisStart) starts with multiple of the ranges or elements in $(D withOneOfThese), then the shortest one matches (if there are two which match which are of the same length (e.g. $(D "a") and $(D 'a')), then the left-most of them in the argument list matches).

- skipOver(alias pred = "a == b",R1,R2) if (is(typeof(binaryFun!(pred)(r1.front,r2.front))))
If $(D startsWith(r1, r2)), consume the corresponding elements off $(D r1) and return $(D true). Otherwise, leave $(D r1) unchanged and return $(D false).

- skipOver(alias pred = "a == b",R,E) if (is(typeof(binaryFun!(pred)(r.front,e))))
Checks whether a range starts with an element, and if so, consume that element off $(D r) and return $(D true). Otherwise, leave $(D r) unchanged and return $(D false).

- skipAll(alias pred = "a == b",R,Es...)
- endsWith(alias pred = "a == b",Range,Ranges...) if (isInputRange!(Range) && Ranges.length > 1 && is(typeof(.endsWith!(pred)(doesThisEnd,withOneOfThese[0])) : bool) && is(typeof(.endsWith!(pred)(doesThisEnd,withOneOfThese[1..__dollar])) : uint))
The reciprocal of $(D startsWith).

- endsWith(alias pred = "a == b",R1,R2) if (isInputRange!(R1) && isInputRange!(R2) && is(typeof(binaryFun!(pred)(doesThisEnd.back,withThis.back)) : bool))
The reciprocal of $(D startsWith).

- endsWith(alias pred = "a == b",R,E) if (isInputRange!(R) && is(typeof(binaryFun!(pred)(doesThisEnd.back,withThis)) : bool))
The reciprocal of $(D startsWith).

- commonPrefix(alias pred = "a == b",R1,R2) if (isForwardRange!(R1) && isForwardRange!(R2))
Returns the common prefix of two ranges. Example:

- findAdjacent(alias pred = "a == b",Range) if (isForwardRange!(Range))
Advances $(D r) until it finds the first two adjacent elements $(D a), $(D b) that satisfy $(D pred(a, b)). Performs $(BIGOH r.length) evaluations of $(D pred). See also $(WEB sgi.com/tech/stl/adjacent_find.html, STL's adjacent_find).

- findAmong(alias pred = "a == b",Range1,Range2) if (isInputRange!(Range1) && isForwardRange!(Range2))
Advances $(D seq) by calling $(D seq.popFront) until either $(D find!(pred)(choices, seq.front)) is $(D true), or $(D seq) becomes empty. Performs $(BIGOH seq.length * choices.length) evaluations of $(D pred). See also $(WEB sgi.com/tech/stl/find_first_of.html, STL's find_first_of).

- count(alias pred = "a == b",Range,E) if (isInputRange!(Range) && is(typeof(binaryFun!(pred)(r.front,value)) == bool))
The first version counts the number of elements $(D x) in $(D r) for which $(D pred(x, value)) is $(D true). $(D pred) defaults to equality. Performs $(BIGOH r.length) evaluations of $(D pred).

- count(alias pred = "a == b",R1,R2) if (isInputRange!(R1) && isForwardRange!(R2) && is(typeof(binaryFun!(pred)(haystack,needle)) == bool))
The first version counts the number of elements $(D x) in $(D r) for which $(D pred(x, value)) is $(D true). $(D pred) defaults to equality. Performs $(BIGOH r.length) evaluations of $(D pred).

- count(alias pred = "true",Range) if (isInputRange!(Range))
The first version counts the number of elements $(D x) in $(D r) for which $(D pred(x, value)) is $(D true). $(D pred) defaults to equality. Performs $(BIGOH r.length) evaluations of $(D pred).

- balancedParens(Range,E) if (isInputRange!(Range) && is(typeof(r.front == lPar)))
Checks whether $(D r) has "balanced parentheses", i.e. all instances of $(D lPar) are closed by corresponding instances of $(D rPar). The parameter $(D maxNestingLevel) controls the nesting level allowed. The most common uses are the default or $(D 0). In the latter case, no nesting is allowed.

- equal(alias pred = "a == b",Range1,Range2) if (isInputRange!(Range1) && isInputRange!(Range2) && is(typeof(binaryFun!(pred)(r1.front,r2.front))))
Returns $(D true) if and only if the two ranges compare equal element for element, according to binary predicate $(D pred). The ranges may have different element types, as long as $(D pred(a, b)) evaluates to $(D bool) for $(D a) in $(D r1) and $(D b) in $(D r2). Performs $(BIGOH min(r1.length, r2.length)) evaluations of $(D pred). See also $(WEB sgi.com/tech/stl/_equal.html, STL's _equal).

- cmp(alias pred = "a < b",R1,R2) if (isInputRange!(R1) && isInputRange!(R2) && !(isSomeString!(R1) && isSomeString!(R2)))
Performs three-way lexicographical comparison on two input ranges according to predicate $(D pred). Iterating $(D r1) and $(D r2) in lockstep, $(D cmp) compares each element $(D e1) of $(D r1) with the corresponding element $(D e2) in $(D r2). If $(D binaryFun!pred(e1, e2)), $(D cmp) returns a negative value. If $(D binaryFun!pred(e2, e1)), $(D cmp) returns a positive value. If one of the ranges has been finished, $(D cmp) returns a negative value if $(D r1) has fewer elements than $(D r2), a positive value if $(D r1) has more elements than $(D r2), and $(D 0) if the ranges have the same number of elements.

- cmp(alias pred = "a < b",R1,R2) if (isSomeString!(R1) && isSomeString!(R2))
- MinType(T...)
- min(T1,T2,T...) if (is(typeof(a < b)))
Returns the minimum of the passed-in values. The type of the result is computed by using $(XREF traits, CommonType).

- MaxType(T...)
- max(T1,T2,T...) if (is(typeof(a < b)))
Returns the maximum of the passed-in values. The type of the result is computed by using $(XREF traits, CommonType).

- minCount(alias pred = "a < b",Range)
Returns the minimum element of a range together with the number of occurrences. The function can actually be used for counting the maximum or any other ordering predicate (that's why $(D maxCount) is not provided).

- minPos(alias pred = "a < b",Range)
Returns the position of the minimum element of forward range $(D range), i.e. a subrange of $(D range) starting at the position of its smallest element and with the same ending as $(D range). The function can actually be used for counting the maximum or any other ordering predicate (that's why $(D maxPos) is not provided).

- mismatch(alias pred = "a == b",Range1,Range2) if (isInputRange!(Range1) && isInputRange!(Range2))
Sequentially compares elements in $(D r1) and $(D r2) in lockstep, and stops at the first mismatch (according to $(D pred), by default equality). Returns a tuple with the reduced ranges that start with the two mismatched values. Performs $(BIGOH min(r1.length, r2.length)) evaluations of $(D pred). See also $(WEB sgi.com/tech/stl/_mismatch.html, STL's _mismatch).

- EditOp
Encodes $(WEB realityinteractive.com/rgrzywinski/archives/000249.html, edit operations) necessary to transform one sequence into another. Given sequences $(D s) (source) and $(D t) (target), a sequence of $(D EditOp) encodes the steps that need to be taken to convert $(D s) into $(D t). For example, if $(D s = "cat") and $(D "cars"), the minimal sequence that transforms $(D s) into $(D t) is: skip two characters, replace 't' with 'r', and insert an 's'. Working with edit operations is useful in applications such as spell-checkers (to find the closest word to a given misspelled word), approximate searches, diff-style programs that compute the difference between files, efficient encoding of patches, DNA sequence analysis, and plagiarism detection.

- Levenshtein(Range,alias equals,CostType = size_t)
- levenshteinDistance(alias equals = "a == b",Range1,Range2) if (isForwardRange!(Range1) && isForwardRange!(Range2))
Returns the $(WEB wikipedia.org/wiki/Levenshtein_distance, Levenshtein distance) between $(D s) and $(D t). The Levenshtein distance computes the minimal amount of edit operations necessary to transform $(D s) into $(D t). Performs $(BIGOH s.length * t.length) evaluations of $(D equals) and occupies $(BIGOH s.length * t.length) storage.

- levenshteinDistanceAndPath(alias equals = "a == b",Range1,Range2) if (isForwardRange!(Range1) && isForwardRange!(Range2))
Returns the Levenshtein distance and the edit path between $(D s) and $(D t).

- copy(Range1,Range2) if (isInputRange!(Range1) && isOutputRange!(Range2,ElementType!(Range1)))
Copies the content of $(D source) into $(D target) and returns the remaining (unfilled) part of $(D target). See also $(WEB sgi.com/tech/stl/_copy.html, STL's _copy). If a behavior similar to $(WEB sgi.com/tech/stl/copy_backward.html, STL's copy_backward) is needed, use $(D copy(retro(source), retro(target))). See also $(XREF range, retro).

- swapRanges(Range1,Range2) if (isInputRange!(Range1) && isInputRange!(Range2) && hasSwappableElements!(Range1) && hasSwappableElements!(Range2) && is(ElementType!(Range1) == ElementType!(Range2)))
Swaps all elements of $(D r1) with successive elements in $(D r2). Returns a tuple containing the remainder portions of $(D r1) and $(D r2) that were not swapped (one of them will be empty). The ranges may be of different types but must have the same element type and support swapping.

- reverse(Range) if (isBidirectionalRange!(Range) && hasSwappableElements!(Range))
Reverses $(D r) in-place. Performs $(D r.length / 2) evaluations of $(D swap). See also $(WEB sgi.com/tech/stl/_reverse.html, STL's _reverse).

- reverse(Char) if (isNarrowString!(Char[]) && !is(Char == const) && !is(Char == immutable))
Reverses $(D r) in-place, where $(D r) is a narrow string (having elements of type $(D char) or $(D wchar)). UTF sequences consisting of multiple code units are preserved properly.

- bringToFront(Range1,Range2) if (isInputRange!(Range1) && isForwardRange!(Range2))
The $(D bringToFront) function has considerable flexibility and usefulness. It can rotate elements in one buffer left or right, swap buffers of equal length, and even move elements across disjoint buffers of different types and different lengths.

- SwapStrategy
Defines the swapping strategy for algorithms that need to swap elements in a range (such as partition and sort). The strategy concerns the swapping of elements that are not the core concern of the algorithm. For example, consider an algorithm that sorts $(D [ "abc", "b", "aBc" ]) according to $(D toUpper(a) < toUpper(b)). That algorithm might choose to swap the two equivalent strings $(D "abc") and $(D "aBc"). That does not affect the sorting since both $(D [ "abc", "aBc", "b" ]) and $(D [ "aBc", "abc", "b" ]) are valid outcomes.

- remove(SwapStrategy s = SwapStrategy.stable,Range,Offset...) if (isBidirectionalRange!(Range) && hasLength!(Range) && s != SwapStrategy.stable && Offset.length >= 1)
Eliminates elements at given offsets from $(D range) and returns the shortened range. In the simplest call, one element is removed.

- remove(SwapStrategy s = SwapStrategy.stable,Range,Offset...) if ((isForwardRange!(Range) && !isBidirectionalRange!(Range) || !hasLength!(Range) || s == SwapStrategy.stable) && Offset.length >= 1)
- remove(alias pred,SwapStrategy s = SwapStrategy.stable,Range) if (isBidirectionalRange!(Range))
Reduces the length of the bidirectional range $(D range) by removing elements that satisfy $(D pred). If $(D s = SwapStrategy.unstable), elements are moved from the right end of the range over the elements to eliminate. If $(D s = SwapStrategy.stable) (the default), elements are moved progressively to front such that their relative order is preserved. Returns the filtered range.

- partition(alias predicate,SwapStrategy ss = SwapStrategy.unstable,Range) if (ss == SwapStrategy.stable && isRandomAccessRange!(Range) || ss != SwapStrategy.stable && isForwardRange!(Range))
Partitions a range in two using $(D pred) as a predicate. Specifically, reorders the range $(D r = [left, right$(RPAREN)) using $(D swap) such that all elements $(D i) for which $(D pred(i)) is $(D true) come before all elements $(D j) for which $(D pred(j)) returns $(D false).

- isPartitioned(alias pred,Range) if (isForwardRange!(Range))
Returns $(D true) if $(D r) is partitioned according to predicate $(D pred).

- partition3(alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range,E) if (ss == SwapStrategy.unstable && isRandomAccessRange!(Range) && hasSwappableElements!(Range) && hasLength!(Range) && is(typeof(binaryFun!(less)(r.front,pivot)) == bool) && is(typeof(binaryFun!(less)(pivot,r.front)) == bool) && is(typeof(binaryFun!(less)(r.front,r.front)) == bool))
Rearranges elements in $(D r) in three adjacent ranges and returns them. The first and leftmost range only contains elements in $(D r) less than $(D pivot). The second and middle range only contains elements in $(D r) that are equal to $(D pivot). Finally, the third and rightmost range only contains elements in $(D r) that are greater than $(D pivot). The less-than test is defined by the binary function $(D less).

- topN(alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range) if (isRandomAccessRange!(Range) && hasLength!(Range))
Reorders the range $(D r) using $(D swap) such that $(D r[nth]) refers to the element that would fall there if the range were fully sorted. In addition, it also partitions $(D r) such that all elements $(D e1) from $(D r[0]) to $(D r[nth]) satisfy $(D !less(r[nth], e1)), and all elements $(D e2) from $(D r[nth]) to $(D r[r.length]) satisfy $(D !less(e2, r[nth])). Effectively, it finds the nth smallest (according to $(D less)) elements in $(D r). Performs $(BIGOH r.length) (if unstable) or $(BIGOH r.length * log(r.length)) (if stable) evaluations of $(D less) and $(D swap). See also $(WEB sgi.com/tech/stl/nth_element.html, STL's nth_element).

- topN(alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range1,Range2) if (isRandomAccessRange!(Range1) && hasLength!(Range1) && isInputRange!(Range2) && is(ElementType!(Range1) == ElementType!(Range2)))
Stores the smallest elements of the two ranges in the left-hand range.

- sort(alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range)
Sorts a random-access range according to predicate $(D less). Performs $(BIGOH r.length * log(r.length)) (if unstable) or $(BIGOH r.length * log(r.length) * log(r.length)) (if stable) evaluations of $(D less) and $(D swap). See also STL's $(WEB sgi.com/tech/stl/_sort.html, _sort) and $(WEB sgi.com/tech/stl/stable_sort.html, stable_sort).

- validPredicates(E,less...)
- multiSort(less...)
Sorts a range by multiple keys. The call $(D multiSort!("a.id < b.id", "a.date > b.date")(r)) sorts the range $(D r) by $(D id) ascending, and sorts elements that have the same $(D id) by $(D date) descending. Such a call is equivalent to $(D sort!"a.id != b.id ? a.id < b.id : a.date > b.date"(r)), but $(D multiSort) is faster because it does fewer comparisons (in addition to being more convenient).

- getPivot(alias less,Range)
- optimisticInsertionSort(alias less,Range)
- swapAt(R)
- sortImpl(alias less,SwapStrategy ss,Range)
- schwartzSort(alias transform,alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range) if (isRandomAccessRange!(Range) && hasLength!(Range))
Sorts a range using an algorithm akin to the $(WEB wikipedia.org/wiki/Schwartzian_transform, Schwartzian transform), also known as the decorate-sort-undecorate pattern in Python and Lisp. (Not to be confused with $(WEB youtube.com/watch?v=S25Zf8svHZQ, the other Schwartz).) This function is helpful when the sort comparison includes an expensive computation. The complexity is the same as that of the corresponding $(D sort), but $(D schwartzSort) evaluates $(D transform) only $(D r.length) times (less than half when compared to regular sorting). The usage can be best illustrated with an example.

- partialSort(alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range) if (isRandomAccessRange!(Range) && hasLength!(Range) && hasSlicing!(Range))
Reorders the random-access range $(D r) such that the range $(D r[0 .. mid]) is the same as if the entire $(D r) were sorted, and leaves the range $(D r[mid .. r.length]) in no particular order. Performs $(BIGOH r.length * log(mid)) evaluations of $(D pred). The implementation simply calls $(D topN!(less, ss)(r, n)) and then $(D sort!(less, ss)(r[0 .. n])).

- completeSort(alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range1,Range2) if (hasLength!(Range2) && hasSlicing!(Range2))
Sorts the random-access range $(D chain(lhs, rhs)) according to predicate $(D less). The left-hand side of the range $(D lhs) is assumed to be already sorted; $(D rhs) is assumed to be unsorted. The exact strategy chosen depends on the relative sizes of $(D lhs) and $(D rhs). Performs $(BIGOH lhs.length + rhs.length * log(rhs.length)) (best case) to $(BIGOH (lhs.length + rhs.length) * log(lhs.length + rhs.length)) (worst-case) evaluations of $(D swap).

- isSorted(alias less = "a < b",Range) if (isForwardRange!(Range))
Checks whether a forward range is sorted according to the comparison operation $(D less). Performs $(BIGOH r.length) evaluations of $(D less).

- makeIndex(alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range,RangeIndex) if (isForwardRange!(Range) && isRandomAccessRange!(RangeIndex) && is(ElementType!(RangeIndex) : ElementType!(Range)*))
Computes an index for $(D r) based on the comparison $(D less). The index is a sorted array of pointers or indices into the original range. This technique is similar to sorting, but it is more flexible because (1) it allows "sorting" of immutable collections, (2) allows binary search even if the original collection does not offer random access, (3) allows multiple indexes, each on a different predicate, and (4) may be faster when dealing with large objects. However, using an index may also be slower under certain circumstances due to the extra indirection, and is always larger than a sorting-based solution because it needs space for the index in addition to the original collection. The complexity is the same as $(D sort)'s.

- makeIndex(alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range,RangeIndex) if (isRandomAccessRange!(Range) && !isInfinite!(Range) && isRandomAccessRange!(RangeIndex) && !isInfinite!(RangeIndex) && isIntegral!(ElementType!(RangeIndex)))
Computes an index for $(D r) based on the comparison $(D less). The index is a sorted array of pointers or indices into the original range. This technique is similar to sorting, but it is more flexible because (1) it allows "sorting" of immutable collections, (2) allows binary search even if the original collection does not offer random access, (3) allows multiple indexes, each on a different predicate, and (4) may be faster when dealing with large objects. However, using an index may also be slower under certain circumstances due to the extra indirection, and is always larger than a sorting-based solution because it needs space for the index in addition to the original collection. The complexity is the same as $(D sort)'s.

- SortOutput
Specifies whether the output of certain algorithm is desired in sorted format.

- topNIndex(alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range,RangeIndex) if (isIntegral!(ElementType!(RangeIndex)))
- topNIndex(alias less = "a < b",SwapStrategy ss = SwapStrategy.unstable,Range,RangeIndex) if (is(ElementType!(RangeIndex) == ElementType!(Range)*))
- canFind(alias pred = "a == b",Range,V) if (is(typeof(find!(pred)(range,value))))
Returns $(D true) if and only if $(D value) can be found in $(D range). Performs $(BIGOH r.length) evaluations of $(D pred).

- canFind(alias pred,Range)
Forwards to $(D any) for backwards compatibility.

- any(alias pred,Range) if (is(typeof(find!(pred)(range))))
Returns $(D true) if and only if a value $(D v) satisfying the predicate $(D pred) can be found in the forward range $(D range). Performs $(BIGOH r.length) evaluations of $(D pred).

- all(alias pred,R) if (isInputRange!(R) && is(typeof(unaryFun!(pred)(range.front))))
Returns $(D true) if and only if all values in $(D range) satisfy the predicate $(D pred). Performs $(BIGOH r.length) evaluations of $(D pred).

- canFindSorted(alias pred = "a < b",Range,V)
- lowerBound(alias pred = "a < b",Range,V)
- upperBound(alias pred = "a < b",Range,V)
- equalRange(alias pred = "a < b",Range,V)
- topNCopy(alias less = "a < b",SRange,TRange) if (isInputRange!(SRange) && isRandomAccessRange!(TRange) && hasLength!(TRange) && hasSlicing!(TRange))
Copies the top $(D n) elements of the input range $(D source) into the random-access range $(D target), where $(D n = target.length). Elements of $(D source) are not touched. If $(D sorted) is $(D true), the target is sorted. Otherwise, the target respects the $(WEB en.wikipedia.org/wiki/Binary_heap, heap property).

- SetUnion(alias less = "a < b",Rs...) if (allSatisfy!(isInputRange,Rs))
Lazily computes the union of two or more ranges $(D rs). The ranges are assumed to be sorted by $(D less). Elements in the output are not unique; the length of the output is the sum of the lengths of the inputs. (The $(D length) member is offered if all ranges also have length.) The element types of all ranges must have a common type.

- setUnion(alias less = "a < b",Rs...)
Lazily computes the union of two or more ranges $(D rs). The ranges are assumed to be sorted by $(D less). Elements in the output are not unique; the length of the output is the sum of the lengths of the inputs. (The $(D length) member is offered if all ranges also have length.) The element types of all ranges must have a common type.

- SetIntersection(alias less = "a < b",Rs...) if (allSatisfy!(isInputRange,Rs))
Lazily computes the intersection of two or more input ranges $(D rs). The ranges are assumed to be sorted by $(D less). The element types of all ranges must have a common type.

- setIntersection(alias less = "a < b",Rs...) if (allSatisfy!(isInputRange,Rs))
Lazily computes the intersection of two or more input ranges $(D rs). The ranges are assumed to be sorted by $(D less). The element types of all ranges must have a common type.

- SetDifference(alias less = "a < b",R1,R2) if (isInputRange!(R1) && isInputRange!(R2))
Lazily computes the difference of $(D r1) and $(D r2). The two ranges are assumed to be sorted by $(D less). The element types of the two ranges must have a common type.

- setDifference(alias less = "a < b",R1,R2)
Lazily computes the difference of $(D r1) and $(D r2). The two ranges are assumed to be sorted by $(D less). The element types of the two ranges must have a common type.

- SetSymmetricDifference(alias less = "a < b",R1,R2) if (isInputRange!(R1) && isInputRange!(R2))
Lazily computes the symmetric difference of $(D r1) and $(D r2), i.e. the elements that are present in exactly one of $(D r1) and $(D r2). The two ranges are assumed to be sorted by $(D less), and the output is also sorted by $(D less). The element types of the two ranges must have a common type.

- setSymmetricDifference(alias less = "a < b",R1,R2)
Lazily computes the symmetric difference of $(D r1) and $(D r2), i.e. the elements that are present in exactly one of $(D r1) and $(D r2). The two ranges are assumed to be sorted by $(D less), and the output is also sorted by $(D less). The element types of the two ranges must have a common type.

- NWayUnion(alias less,RangeOfRanges)
Computes the union of multiple sets. The input sets are passed as a range of ranges and each is assumed to be sorted by $(D less). Computation is done lazily, one union element at a time. The complexity of one $(D popFront) operation is $(BIGOH log(ror.length)). However, the length of $(D ror) decreases as ranges in it are exhausted, so the complexity of a full pass through $(D NWayUnion) is dependent on the distribution of the lengths of ranges contained within $(D ror). If all ranges have the same length $(D n) (worst case scenario), the complexity of a full pass through $(D NWayUnion) is $(BIGOH n * ror.length * log(ror.length)), i.e., $(D log(ror.length)) times worse than just spanning all ranges in turn. The output comes sorted (unstably) by $(D less).

- nWayUnion(alias less = "a < b",RangeOfRanges)
Computes the union of multiple sets. The input sets are passed as a range of ranges and each is assumed to be sorted by $(D less). Computation is done lazily, one union element at a time. The complexity of one $(D popFront) operation is $(BIGOH log(ror.length)). However, the length of $(D ror) decreases as ranges in it are exhausted, so the complexity of a full pass through $(D NWayUnion) is dependent on the distribution of the lengths of ranges contained within $(D ror). If all ranges have the same length $(D n) (worst case scenario), the complexity of a full pass through $(D NWayUnion) is $(BIGOH n * ror.length * log(ror.length)), i.e., $(D log(ror.length)) times worse than just spanning all ranges in turn. The output comes sorted (unstably) by $(D less).

- largestPartialIntersection(alias less = "a < b",RangeOfRanges,Range)
Given a range of sorted forward ranges $(D ror), copies to $(D tgt) the elements that are common to most ranges, along with their number of occurrences. All ranges in $(D ror) are assumed to be sorted by $(D less). Only the most frequent $(D tgt.length) elements are returned.

- largestPartialIntersectionWeighted(alias less = "a < b",RangeOfRanges,Range,WeightsAA)
Similar to $(D largestPartialIntersection), but associates a weight with each distinct element in the intersection.