1 // Written in the D programming language. 2 3 /** 4 This package implements generic algorithms oriented towards the processing of 5 sequences. Sequences processed by these functions define range-based 6 interfaces. See also $(MREF_ALTTEXT Reference on ranges, std, range) and 7 $(HTTP ddili.org/ders/d.en/ranges.html, tutorial on ranges). 8 9 $(SCRIPT inhibitQuickIndex = 1;) 10 11 Algorithms are categorized into the following submodules: 12 13 $(DIVC quickindex, 14 $(BOOKTABLE , 15 $(TR $(TH Submodule) $(TH Functions) 16 ) 17 $(TR 18 $(TDNW $(SUBMODULE Searching, searching)) 19 $(TD 20 $(SUBREF searching, all) 21 $(SUBREF searching, any) 22 $(SUBREF searching, balancedParens) 23 $(SUBREF searching, boyerMooreFinder) 24 $(SUBREF searching, canFind) 25 $(SUBREF searching, commonPrefix) 26 $(SUBREF searching, count) 27 $(SUBREF searching, countUntil) 28 $(SUBREF searching, endsWith) 29 $(SUBREF searching, find) 30 $(SUBREF searching, findAdjacent) 31 $(SUBREF searching, findAmong) 32 $(SUBREF searching, findSkip) 33 $(SUBREF searching, findSplit) 34 $(SUBREF searching, findSplitAfter) 35 $(SUBREF searching, findSplitBefore) 36 $(SUBREF searching, minCount) 37 $(SUBREF searching, maxCount) 38 $(SUBREF searching, minElement) 39 $(SUBREF searching, maxElement) 40 $(SUBREF searching, minIndex) 41 $(SUBREF searching, maxIndex) 42 $(SUBREF searching, minPos) 43 $(SUBREF searching, maxPos) 44 $(SUBREF searching, skipOver) 45 $(SUBREF searching, startsWith) 46 $(SUBREF searching, until) 47 ) 48 ) 49 $(TR 50 $(TDNW $(SUBMODULE Comparison, comparison)) 51 $(TD 52 $(SUBREF comparison, among) 53 $(SUBREF comparison, castSwitch) 54 $(SUBREF comparison, clamp) 55 $(SUBREF comparison, cmp) 56 $(SUBREF comparison, either) 57 $(SUBREF comparison, equal) 58 $(SUBREF comparison, isPermutation) 59 $(SUBREF comparison, isSameLength) 60 $(SUBREF comparison, levenshteinDistance) 61 $(SUBREF comparison, levenshteinDistanceAndPath) 62 $(SUBREF comparison, max) 63 $(SUBREF comparison, min) 64 $(SUBREF comparison, mismatch) 65 $(SUBREF comparison, predSwitch) 66 ) 67 ) 68 $(TR 69 $(TDNW $(SUBMODULE Iteration, iteration)) 70 $(TD 71 $(SUBREF iteration, cache) 72 $(SUBREF iteration, cacheBidirectional) 73 $(SUBREF iteration, chunkBy) 74 $(SUBREF iteration, cumulativeFold) 75 $(SUBREF iteration, each) 76 $(SUBREF iteration, filter) 77 $(SUBREF iteration, filterBidirectional) 78 $(SUBREF iteration, fold) 79 $(SUBREF iteration, group) 80 $(SUBREF iteration, joiner) 81 $(SUBREF iteration, map) 82 $(SUBREF iteration, mean) 83 $(SUBREF iteration, permutations) 84 $(SUBREF iteration, reduce) 85 $(SUBREF iteration, splitWhen) 86 $(SUBREF iteration, splitter) 87 $(SUBREF iteration, substitute) 88 $(SUBREF iteration, sum) 89 $(SUBREF iteration, uniq) 90 ) 91 ) 92 $(TR 93 $(TDNW $(SUBMODULE Sorting, sorting)) 94 $(TD 95 $(SUBREF sorting, completeSort) 96 $(SUBREF sorting, isPartitioned) 97 $(SUBREF sorting, isSorted) 98 $(SUBREF sorting, isStrictlyMonotonic) 99 $(SUBREF sorting, ordered) 100 $(SUBREF sorting, strictlyOrdered) 101 $(SUBREF sorting, makeIndex) 102 $(SUBREF sorting, merge) 103 $(SUBREF sorting, multiSort) 104 $(SUBREF sorting, nextEvenPermutation) 105 $(SUBREF sorting, nextPermutation) 106 $(SUBREF sorting, partialSort) 107 $(SUBREF sorting, partition) 108 $(SUBREF sorting, partition3) 109 $(SUBREF sorting, schwartzSort) 110 $(SUBREF sorting, sort) 111 $(SUBREF sorting, topN) 112 $(SUBREF sorting, topNCopy) 113 $(SUBREF sorting, topNIndex) 114 ) 115 ) 116 $(TR 117 $(TDNW Set operations $(BR)($(SUBMODULE setops, setops))) 118 $(TD 119 $(SUBREF setops, cartesianProduct) 120 $(SUBREF setops, largestPartialIntersection) 121 $(SUBREF setops, largestPartialIntersectionWeighted) 122 $(SUBREF setops, multiwayMerge) 123 $(SUBREF setops, multiwayUnion) 124 $(SUBREF setops, setDifference) 125 $(SUBREF setops, setIntersection) 126 $(SUBREF setops, setSymmetricDifference) 127 ) 128 ) 129 $(TR 130 $(TDNW $(SUBMODULE Mutation, mutation)) 131 $(TD 132 $(SUBREF mutation, bringToFront) 133 $(SUBREF mutation, copy) 134 $(SUBREF mutation, fill) 135 $(SUBREF mutation, initializeAll) 136 $(SUBREF mutation, move) 137 $(SUBREF mutation, moveAll) 138 $(SUBREF mutation, moveSome) 139 $(SUBREF mutation, moveEmplace) 140 $(SUBREF mutation, moveEmplaceAll) 141 $(SUBREF mutation, moveEmplaceSome) 142 $(SUBREF mutation, remove) 143 $(SUBREF mutation, reverse) 144 $(SUBREF mutation, strip) 145 $(SUBREF mutation, stripLeft) 146 $(SUBREF mutation, stripRight) 147 $(SUBREF mutation, swap) 148 $(SUBREF mutation, swapRanges) 149 $(SUBREF mutation, uninitializedFill) 150 ) 151 ) 152 )) 153 154 Many functions in this package are parameterized with a $(GLOSSARY predicate). 155 The predicate may be any suitable callable type 156 (a function, a delegate, a $(GLOSSARY functor), or a lambda), or a 157 compile-time string. The string may consist of $(B any) legal D 158 expression that uses the symbol `a` (for unary functions) or the 159 symbols `a` and `b` (for binary functions). These names will NOT 160 interfere with other homonym symbols in user code because they are 161 evaluated in a different context. The default for all binary 162 comparison predicates is `"a == b"` for unordered operations and 163 `"a < b"` for ordered operations. 164 165 Example: 166 167 ---- 168 int[] a = ...; 169 static bool greater(int a, int b) 170 { 171 return a > b; 172 } 173 sort!greater(a); // predicate as alias 174 sort!((a, b) => a > b)(a); // predicate as a lambda. 175 sort!"a > b"(a); // predicate as string 176 // (no ambiguity with array name) 177 sort(a); // no predicate, "a < b" is implicit 178 ---- 179 180 Macros: 181 SUBMODULE = $(MREF_ALTTEXT $1, std, algorithm, $2) 182 SUBREF = $(REF_ALTTEXT $(TT $2), $2, std, algorithm, $1)$(NBSP) 183 184 Copyright: Andrei Alexandrescu 2008-. 185 186 License: $(HTTP boost.org/LICENSE_1_0.txt, Boost License 1.0). 187 188 Authors: $(HTTP erdani.com, Andrei Alexandrescu) 189 190 Source: $(PHOBOSSRC std/algorithm/package.d) 191 */ 192 module std.algorithm; 193 194 public import std.algorithm.comparison; 195 public import std.algorithm.iteration; 196 public import std.algorithm.mutation; 197 public import std.algorithm.searching; 198 public import std.algorithm.setops; 199 public import std.algorithm.sorting; 200 201 static import std.functional; 202