ocean.core.array.Transformation

Collection of utilities to create new data based on arrays.

All functions in this module must never mutate their arguments. Some of them allocate new GC memory to store return data, some request explicit buffer argument for result.

Based on tango.core.Array module from Tango library.

Members

Functions

differenceOf
T[] differenceOf(T[] setA, T[] setB, Pred pred)

Returns a new array containing all elements in setA which are not present in setB and the elements in setB which are not present in setA. Both setA and setB are required to be sorted. Comparisons will be performed using the supplied predicate or '<' if none is supplied.

fill
void fill(T[] array, T[] elements)

Assigns elements to an array.

filter
T[] filter(T[] array, Pred pred, Buffer!(T) buf)

Performs a linear scan of buf from [0 .. buf.length$(RP), creating a new array with just the elements that satisfy pred. The relative order of elements will be preserved.

filter
T[] filter(T[] array, Pred pred, T[] pseudo_buf)
Undocumented in source. Be warned that the author may not have intended to support it.
intersectionOf
T[] intersectionOf(T[] setA, T[] setB, Pred pred)

Computes the intersection of setA and setB as a set operation and returns the retult in a new sorted array. Both setA and setB are required to be sorted. If either setA or setB contain duplicates, the result will contain the smaller number of duplicates from setA and setB. All entries will be copied from setA. Comparisons will be performed using the supplied predicate or '<' if none is supplied.

map
U[] map(T[] array, MapFunc func, Buffer!(U) buf)

Apply a function to each element an array. The function's return values are stored in another array.

map
U[] map(T[] array, MapFunc func, U[] pseudo_buff)
Undocumented in source. Be warned that the author may not have intended to support it.
missingFrom
T[] missingFrom(T[] setA, T[] setB, Pred pred)

Returns a new array containing all elements in setA which are not present in setB. Both setA and setB are required to be sorted. Comparisons will be performed using the supplied predicate or '<' if none is supplied.

reduce
ReturnTypeOf!(ReduceFunc) reduce(T[] array, ReduceFunc func)

Reduce an array of elements to a single element, using a user-supplied reductor function.

remove
T[] remove(T[] source, T[] match, Buffer!(T) result)

Removes all instances of match from source.

remove
T[] remove(T[] source, T[] match, T[] result)
Undocumented in source. Be warned that the author may not have intended to support it.
split
T3[] split(T1[] src, T2[] pattern, Buffer!(T3) result)

Split the provided array wherever a pattern instance is found, and return the resultant segments. The pattern is excluded from each of the segments.

split
T3[][] split(T1[] src, T2[] pattern, T3[][] result)
Undocumented in source. Be warned that the author may not have intended to support it.
substitute
T[] substitute(T[] source, T[] match, T[] replacement, T[] result)
Undocumented in source. Be warned that the author may not have intended to support it.
substitute
T[] substitute(T[] source, T[] match, T[] replacement, Buffer!(T) result)

Substitute all instances of match from source. Set replacement to null in order to remove instead of replace (or use the remove() function, below).

toArray
T[] toArray(T val)

Creates a single element dynamic array that slices val. This will not allocate memory in contrast to the 'val' expression.

unionOf
T[] unionOf(T[] setA, T[] setB, Pred pred)

Computes the union of setA and setB as a set operation and returns the retult in a new sorted array. Both setA and setB are required to be sorted. If either setA or setB contain duplicates, the result will contain the larger number of duplicates from setA and setB. When an overlap occurs, entries will be copied from setA. Comparisons will be performed using the supplied predicate or '<' if none is supplied.

Meta

License

Tango Dual License: 3-Clause BSD License / Academic Free License v3.0. See LICENSE_TANGO.txt for details.