array

array is a collection of array template functions designed primarily to be applicable to D's built in array types. All array functions are designed to be usable as implicit array member functions. I.e the following are equivalent:
	fun(arr,args);
	arr.fun(args);


class ElementNotFoundException: object.Exception;
Thrown by indexOf when no element is found

template fold(Array,RetTy,FunTy)


MakeDynamic!(RetTy) fold(Array arr, RetTy init, FunTy combiner);
Fold encapulates a simple pattern of recursion for processing arrays. This function recursively applies the function/delegate combiner on consecutive elements of the array arr until only one element remains. It then returns that element. init is the first element fed to the combiner. The result is equivalent to:
	combiner(init,fold(arr[1..$],arr[0],combiner));


Requirements on types:
FunTy is a function/delegate:
	RetTy fun(RetTy a, Elem b);
Array is anything that foreach can iterate over.

Elem is anything implicitly convertible from the element type of Array.

template findMax(Array,Pred)
template findMax(Array)


size_t findMax(Array arr, Pred pred);
Params:
Array arr non-empty array
Pred pred an optional ordering predicate.

Returns:
The index of the maximum element of the array arr. size_t.max (-1) if the array is empty

template findMin(Array,Pred)
template findMin(Array)


size_t findMin(Array arr, Pred pred);
Params:
Array arr non-empty array
Pred pred an optional ordering predicate.

Returns:
The index of the minimum element of the array arr. size_t.max (-1) if the array is empty

template max(Array,Pred)
template max(Array)


ElementType!(Array) max(Array arr, Pred pred);
Params:
Array arr non-empty array
Pred pred an optional ordering predicate.

Returns:
The maximum element of the array arr.

template min(Array,Pred)
template min(Array)


ElementType!(Array) min(Array arr, Pred pred);
Params:
Array arr non-empty array
Pred pred an optional ordering predicate.

Returns:
The minimum element of the array arr.

template indexOf(Array,Elem)


size_t indexOf(Array arr, Elem e);
Params:
Array arr array
Elem e element to be found or a function/delegate predicate

Returns:
The index of the first occurence of e in arr or the first element in arr where the predicate is true.

Throws:
ElementNotFoundException

template find(Array,Elem)


size_t find(Array arr, Elem e);
Params:
Array arr array
Elem e element, function/delegate predicate or a subarray

Returns:
The index of the first occurence of e in arr or the first element in arr where the predicate is true.

size_t.max (-1) if not found

template rfind(Array,Elem)


size_t rfind(Array arr, Elem e);
Params:
Array arr array
Elem e element, function/delegate predicate or a subarray

Returns:
The index of the last occurence of e in arr or the last element in arr where the predicate is true.

size_t.max (-1) if not found

template split(Array,Delim)


ElementType!(Array)[][] split(Array arr, Delim delim);
Splits the array arr into an array of subarrays of arr.

Params:
Delim delim element, array of elements or predicate on which the array should be split.

template join(Array,Elem)
template join(Array)


ElementType!(Array) join(Array arr, Elem delim);
Concatenate all elements of an array, using an optional separator

Params:
Elem delim single element or array of elements

template map(Array,FunTy)


RetType!(FunTy,ElementType!(Array))[] map(Array arr, FunTy fun);
Map an array over the given function/delegate, returning an array of the result

template doMap(Array,FunTy)


void doMap(Array arr, FunTy fun);
inplace version of map()

template filter(Array,Pred)


MakeDynamic!(Array) filter(Array arr, Pred pred);
Maps the array arr over the given predicate pred. Returns an array of the elements for which the predicate is true

template count(Array,Pred)


size_t count(Array arr, Pred pred);
Returns:
A count of the number of elements of arr where the predicate pred is true

template sort(Array,Pred)
template sort(Array)


MakeDynamic!(Array) sort(Array arr, Pred wrongOrder);
Return a sorted version of array arr.

Params:
Pred wrongOrder optional binary ordering predicate

template doSort(Array,Pred)
template doSort(Array)


void doSort(Array array, Pred wrongOrder);
Sort the elements of the array inplace. Not stable.

Params:
Pred wrongOrder optional ordering predicate

template doStableSort(Array,Pred)
template doStableSort(Array)


void doStableSort(Array arr, Pred wrongOrder);
stable in-place array sort

template stableSort(Array,Pred)
template stableSort(Array)


MakeDynamic!(Array) stableSort(Array arr, Pred wrongOrder);
Returns a sorted version of array arr. The sort is stable.

template reverse(Array)


MakeDynamic!(Array) reverse(Array arr);
Return a reversed copy of a given array

template doReverse(Array)


void doReverse(Array arr);
In-place reverse the contents of the given array

template repeat(Array,Integer)


MakeDynamic!(Array) repeat(Array arr, Integer n);
Repeats the given array n times


Page generated by Ddoc.