D Programming Language
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. Page wiki View or edit the community-maintained wiki page associated with this page.

# std.algorithm

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.

Algorithms are categorized into the following submodules:

Category | Submodule | Functions
--- | --- | ---
Searching | std.algorithm.searching | all any balancedParens boyerMooreFinder canFind commonPrefix count countUntil endsWith find findAdjacent findAmong findSkip findSplit findSplitAfter findSplitBefore minCount minPos skipOver startsWith until
Comparison | std.algorithm.comparison | among castSwitch clamp cmp equal levenshteinDistance levenshteinDistanceAndPath max min mismatch predSwitch
Iteration | std.algorithm.iteration | cache cacheBidirectional chunkBy each filter filterBidirectional group joiner map reduce splitter sum uniq
Sorting | std.algorithm.sorting | completeSort isPartitioned isSorted makeIndex multiSort nextEvenPermutation nextPermutation partialSort partition partition3 schwartzSort sort topN topNCopy topNIndex
Set operations | std.algorithm.setops | cartesianProduct largestPartialIntersection largestPartialIntersectionWeighted nWayUnion setDifference setIntersection setSymmetricDifference setUnion
Mutation | std.algorithm.mutation | bringToFront copy fill initializeAll move moveAll moveSome remove reverse strip stripLeft stripRight swap swapRanges uninitializedFill
Utility | - | forward

Many functions in this package are parameterized with a function or a predicate. The predicate may be passed either as a function name, a delegate name, a functor name, 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.

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

License:
Boost License 1.0.
Authors:
Andrei Alexandrescu

Source: std/algorithm/package.d

Andrei Alexandrescu 2008-. | Page generated by Ddoc on Sat Apr 25 12:22:56 2015