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

Triple
alias Triple(T, U, V) = Tuple!(T, U, V)

Triple. TODO std.typecons

elementCombinations
alias elementCombinations = cartesianProduct

More descriptive alias.

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.

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.

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

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)
isAmong
bool isAmong(Value value, Values values)
isAnagramOf
auto isAnagramOf(R1 r1, R2 r2)

Return true if s1 is an Anagram of s2.

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

Python Style Length Alias.

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

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=2.

splicer3
auto splicer3(T[] x)

Specialization of splicerN to N=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.

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.

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.

Structs

Limits
struct Limits(T)

Limit/Span (Min,Max) Pair.

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