algorithm_ex

Extensions to std.algorithm.

Members

Aliases

Pair
alias Pair(T, U) = Tuple!(T, U)

Pair. TODO std.typecons

Quadruple
alias Quadruple(T, U, V, W) = Tuple!(T, U, V, W)

Quadruple. TODO std.typecons

Sink
alias Sink = OutputRange
Undocumented in source.
Source
alias Source = InputRange
Undocumented in source.
Triple
alias Triple(T, U, V) = Tuple!(T, U, V)

Triple. TODO std.typecons

containedIn
alias containedIn = sliceOf
Undocumented in source.
coveredBy
alias coveredBy = sliceOf
Undocumented in source.
doN
alias doN = doTimes
Undocumented in source.
dropAllOf
alias dropAllOf = dropWhile
Undocumented in source.
dropUntil
alias dropUntil = find
Undocumented in source.
elementCombinations
alias elementCombinations = cartesianProduct

More descriptive alias.

includedIn
alias includedIn = sliceOf
Undocumented in source.
isPalindrome
alias isPalindrome = isSymmetric
Undocumented in source.
isPermutationOf
alias isPermutationOf = isAnagramOf
Undocumented in source.
largest
alias largest = maxElement
Undocumented in source.
loop
alias loop = doTimes
Undocumented in source.
lstrip
alias lstrip = dropWhile
Undocumented in source.
packBPRL
alias packBPRL = packBitParallelRunLengths
Undocumented in source.
partOf
alias partOf = sliceOf
Undocumented in source.
repeat
alias repeat = doTimes
Undocumented in source.
retroCycle
alias retroCycle = compose!(cycle, retro)
Undocumented in source.
sadd
alias sadd = addu
Undocumented in source.
smallest
alias smallest = minElement
Undocumented in source.
smul
alias smul = mulu
Undocumented in source.
ssub
alias ssub = subu
Undocumented in source.
stripFront
alias stripFront = dropWhile
Undocumented in source.
tail
alias tail = dropOne
Undocumented in source.
takeAllOf
alias takeAllOf = takeWhile
Undocumented in source.
takeUntil
alias takeUntil = until
Undocumented in source.

Enums

Reduction
enum Reduction
Undocumented in source.
isIntLike
eponymoustemplate isIntLike(T)
Undocumented in source.

Functions

append
R append(R data, Args args)

Append Arguments $(args) to data. TODO Add support for other Random Access Ranges such as std.container.Array See also: http://forum.dlang.org/thread/mevnosveagdiswkxtbrv@forum.dlang.org?page=1

apply
auto apply(N n)

Create Range of Elements Generated by fun.

areColinear
bool areColinear(T a, T b)

Check if a and b are colinear.

areStrictlyOrdered
bool areStrictlyOrdered(Ts args)

Return true if all arguments args are strictly ordered, that is args[0] < args[1] < args[2] < ... . TODO: CT-variant See also: http://forum.dlang.org/thread/wzsdhzycwqyrvqmmttix@forum.dlang.org?page=2#post-vprvhifglfegnlvzqmjj:40forum.dlang.org

areUnstrictlyOrdered
bool areUnstrictlyOrdered(Ts args)

Return true if all arguments args are unstrictly ordered, that is args[0] <= args[1] <= args[2] <= ... . TODO: CT-variant See also: http://forum.dlang.org/thread/wzsdhzycwqyrvqmmttix@forum.dlang.org?page=2#post-vprvhifglfegnlvzqmjj:40forum.dlang.org

binarySearch
size_t binarySearch(T[] values, U value)

This function returns the index of the value if it exist among values, size_t.max otherwise.

countsAtLeast
bool countsAtLeast(R r, size_t minCount)

Check if r counts to at least minCount elements.

countsAtMost
bool countsAtMost(R r, size_t maxCount)

Check if r counts to at most maxCount elements.

countsExactly
bool countsExactly(R r, size_t exactCount)

Check if r counts to exactly exactCount elements.

distinct
auto distinct(R r)

Distinct Elements of r.

doTimes
void doTimes(uint n, void expr)

Execute Expression expr the same way n times.

doTimes
void doTimes(void expr)

Execute Expression expr inline the same way n times. n must be a constant known at compile time.

dropWhile
auto dropWhile(R range, E element)
Undocumented in source. Be warned that the author may not have intended to support it.
either
CommonType!Ts either(Ts a)
either
auto ref either(Ts a)

This overload enables, when possible, lvalue return. TODO should we limit this template to a.length >= 2

either_r
T either_r(T a)
Undocumented in source. Be warned that the author may not have intended to support it.
either_r
CommonType!(A, Bs) either_r(A a, Bs bs)
Undocumented in source. Be warned that the author may not have intended to support it.
every
CommonType!T every(T a)
every
auto ref every(T a)

This overload enables, when possible, lvalue return.

fibonacci
auto fibonacci(T nth)

$(LUCKY Fibonacci) Numbers (Infinite Range). See also: http://forum.dlang.org/thread/dqlrfoxzsppylcgljyyf@forum.dlang.org#post-mailman.1072.1350619455.5162.digitalmars-d-learn:40puremagic.com See also: https://www.reddit.com/r/programming/comments/rif9x/uniform_function_call_syntax_for_the_d/

findAllOfAnyInOrder
Tuple!(R, size_t)[] findAllOfAnyInOrder(R haystack, R[] needles)
Undocumented in source. Be warned that the author may not have intended to support it.
findFirstOfAnyInOrder
Tuple!(R, size_t) findFirstOfAnyInOrder(R haystack, R[] needles)

Find First Occurrence any of needles in haystack. Like to std.algorithm.find but takes an array of needles as argument instead of a variadic list of key needle arguments. Return found range plus index into needles starting at 1 upon.

findInOrder
auto findInOrder(R haystack, E needles)

Find needles In Order in haystack.

findPopAfter
auto findPopAfter(R1 haystack, R2 needle)

Variant of findSplitAfter that destructively pops everything up to, including, needle from haystack.

findPopBefore
auto findPopBefore(R1 haystack, R2 needle)

Variant of findSplitBefore that destructively pops everything up to, not including, needle from haystack.

forwardDifference
auto forwardDifference(R r)

Compute Forward Difference of range.

hasContents
bool hasContents(T a)
hasHoles
bool hasHoles(R r)
Undocumented in source. Be warned that the author may not have intended to support it.
isAmong
bool isAmong(Value value, Values values)
isAnagramOf
auto isAnagramOf(R1 r1, R2 r2)

Return true if s1 is an Anagram of s2. Equal arguments are not considered to be an anagrams of each other.

isLinearRamp
bool isLinearRamp(R r, size_t step)
isSymmetric
bool isSymmetric(R range, size_t minLength)
len
auto len(T a)

Python Style Length Alias.

limits
auto limits()
Undocumented in source. Be warned that the author may not have intended to support it.
maxElement
auto maxElement(R range)
minElement
auto minElement(R range)
minmaxElement
auto minmaxElement(R range)
moveUntil
auto moveUntil(R r)
Undocumented in source. Be warned that the author may not have intended to support it.
moveWhile
auto moveWhile(R r)
Undocumented in source. Be warned that the author may not have intended to support it.
orderInPlace
void orderInPlace(T t)

In Place Ordering (in Sorted Order) of all Elements t. See also: https://stackoverflow.com/questions/21102646/in-place-ordering-of-elements/ See also: http://forum.dlang.org/thread/eweortsmcmibppmvtriw@forum.dlang.org#post-eweortsmcmibppmvtriw:40forum.dlang.org

overlap
inout(T[]) overlap(inout(T[]) a, inout(T[]) b)
overlapInOrder
inout(T[]) overlapInOrder(inout(T[]) a, inout(T[]) b)
overlaps
bool overlaps(const(T)[] r1, const(T)[] r2)

Helper for overlap(). Copied from std.array with simplified return expression.

packBitParallelRunLengths
auto ref packBitParallelRunLengths(R x)
Undocumented in source. Be warned that the author may not have intended to support it.
pair
auto pair(T t, U u)

Instantiator for Pair.

quadruple
auto quadruple(T t, U u, V v, W w)

Instantiator for Quadruple.

reset
auto ref reset(T a)

Reset a to its default value. See also: std.typecons.Nullable.nullify

resetAllMembers
void resetAllMembers(T c)

Reset all members in aggregate instance c. See also: http://forum.dlang.org/post/ckitmpguywfitgadfpkv@forum.dlang.org See also: http://forum.dlang.org/post/fbs8b5$5bu$1@digitalmars.com

s
T[n] s(T[n] values)
Undocumented in source. Be warned that the author may not have intended to support it.
set
T set(T a, U value)

Generic Member Setter. See also: http://forum.dlang.org/thread/fdjkijrtduraaajlxxne@forum.dlang.org

sliceOf
bool sliceOf(T[] part, T[] whole)
Undocumented in source. Be warned that the author may not have intended to support it.
split
auto split(R haystack)

Simpler variant of Phobos' split.

splitAfter
auto splitAfter(R haystack)
Undocumented in source. Be warned that the author may not have intended to support it.
splitBefore
auto splitBefore(R haystack)

Simpler variant of Phobos' splitBefore.

stableSort
auto ref stableSort(T a)

Stable Variant of Quick Sort. See also: http://forum.dlang.org/thread/gjuvmrypvxeebvztszpr@forum.dlang.org

staticArray
auto staticArray()
str
string str(T a)

Python Style To-String-Conversion Alias.

takeWhile
auto takeWhile(R range, E element)
Undocumented in source. Be warned that the author may not have intended to support it.
times
void times(N n)

Execute Expression action the same way n times.

triple
auto triple(T t, U u, V v)

Instantiator for Triple.

tryEvery
CommonType!T[] tryEvery(S whole, T parts)

Evaluate all parts possibly digesting whole. If all values of parts implicitly convert to bool true return the values as an array, otherwise restore whole and return null.

typestringof
auto typestringof(T a)
Undocumented in source. Be warned that the author may not have intended to support it.
windowedReduce
auto ref windowedReduce(R range)

Generalized Windowed Reduce. See also: https://stackoverflow.com/questions/21004944/forward-difference-algorithm See also: http://forum.dlang.org/thread/ujouqtqeehkegmtaxebg@forum.dlang.org#post-lczzsypupcfigttghkwx:40forum.dlang.org See also: http://rosettacode.org/wiki/Forward_difference#D

zipWith
auto zipWith(Ranges ranges)

Zip ranges together with operation fun. TODO Remove when Issue 8715 is fixed providing zipWith

zipWith
auto zipWith(StoppingPolicy sp, Ranges ranges)
Undocumented in source. Be warned that the author may not have intended to support it.

Structs

Limits
struct Limits(T)

Limit/Span (Min,Max) Pair. Todo: Decide on either Span, MinMax or Limits See also: https://stackoverflow.com/questions/21241878/generic-span-type-in-phobos

Templates

expand
template expand(alias array, size_t idx = 0)

Expand Static array into a parameter arguments (AliasSeq!). See also: http://forum.dlang.org/thread/hwellpcaomwbpnpofzlx@forum.dlang.org?page=1

isAmong
template isAmong(values...)
naryFun
template naryFun(string fun)
Undocumented in source.
sort
template sort(alias less = `a < b`, SwapStrategy ss = SwapStrategy.unstable)

Allow Static Arrays to be sorted without []. See also: http://forum.dlang.org/thread/jhzurojjnlkatjdgcfhg@forum.dlang.org

Meta