nxt.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

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.

halved
alias halved = spliced2
Undocumented in source.
isPermutationOf
alias isPermutationOf = isAnagramOf
Undocumented in source.
loop
alias loop = doTimes
Undocumented in source.
lstrip
alias lstrip = dropWhile
Undocumented in source.
packBPRL
alias packBPRL = packBitParallelRunLengths
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.
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

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. a and b are colinear iff a.x / a.y == b.x / b.y holds. We can avoid the division by multiplying out.

areStrictlyOrdered
bool areStrictlyOrdered(Ts args)

Return true if all arguments args are strictly ordered, that is args[0] < args[1] < args[2] < ... .

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

bruteCast
auto bruteCast(IT it)

Allows forbidden casts.

collect
Container collect(Range r)

Collect/Gather the elements of r into a Container and return it.

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.
eitherRef
Ts[0] eitherRef(Ts a)

This overload enables, when possible, lvalue return.

equalLength
bool equalLength(R r, Ss ss)
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).

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.

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.

isDefaulted
bool isDefaulted(T a)
isLinearRamp
bool isLinearRamp(R r, size_t step)
isPalindrome
bool isPalindrome(R range, size_t lengthMin)
isSliceOf
bool isSliceOf(T[] part, T[] whole)
Undocumented in source. Be warned that the author may not have intended to support it.
isSymmetric
bool isSymmetric(R range)
len
auto len(T a)

Python Style Length Alias.

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

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.

resetAllMembers
void resetAllMembers(T c)

Reset all members in aggregate instance c.

set
T set(T a, U value)

Generic Member Setter.

spliced2
auto spliced2(T[] x)
spliced3
auto spliced3(T[] x)
splicer2
auto splicer2(T[] x)

Specialization of splicerN to N being 2.

splicer3
auto splicer3(T[] x)

Specialization of splicerN to N being 3.

splicerN
auto splicerN(T[] x)

Splice x in N parts, all as equal in lengths as possible.

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.

splitterN
auto splitterN(R range, S separators)

Split range using multiple separators stored as elements in separators.

stableSort
auto ref stableSort(T a)

Stable Variant of Quick Sort.

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.

use
auto use(T t)
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.

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

Templates

endsWith
template endsWith(needles...)

TOOD Merge into Phobos' endsWith.

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

Expand Static array into a parameter arguments (AliasSeq!).

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 [].

startsWith
template startsWith(needles...)

TOOD Merge into Phobos' startsWith.

Meta

Authors

TODO: merge stuff from algorithm_ex_2.d