This package implements generic algorithms oriented towards the processing of sequences. Sequences processed by these functions define range-based interfaces. See also Reference on ranges and tutorial on ranges. interfaces. See also Reference on ranges and tutorial on ranges.

Algorithms are categorized into the following submodules:

Many functions in this package are parameterized with a predicate. The predicate may be any suitable callable type (a function, a delegate, a functor, or a lambda), or a compile-time string. The string may consist of any legal D expression that uses the symbol a (for unary functions) or the symbols a and 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 "a == b" for unordered operations and "a < b" for ordered operations.


module std.algorithm.comparison

This module contains generic comparison algorithms.

module std.algorithm.internal

Helper functions for std.algorithm package.

module std.algorithm.iteration

This module contains generic iteration algorithms.

module std.algorithm.mutation

This module contains generic mutation algorithms.

module std.algorithm.searching

This module contains generic searching algorithms.

module std.algorithm.setops

This module contains generic algorithms that implement set operations.

module std.algorithm.sorting

This module contains generic sorting algorithms.


1 int[] a = ...;
2 static bool greater(int a, int b)
3 {
4     return a > b;
5 }
6 sort!greater(a);           // predicate as alias
7 sort!((a, b) => a > b)(a); // predicate as a lambda.
8 sort!"a > b"(a);           // predicate as string
9                            // (no ambiguity with array name)
10 sort(a);                   // no predicate, "a < b" is implicit


Suggestion Box / Bug Report