Buffer

interface Buffer<out T>

A generic read-only random-access structure for both primitives and objects.

Buffer is in general identity-free. Buffer.contentEquals should be used for content equality checks.

Parameters

T

the type of elements contained in the buffer.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
abstract operator fun get(index: Int): T

Gets element at given index.

Link copied to clipboard
abstract operator fun iterator(): Iterator<T>

Iterates over all elements.

Link copied to clipboard
abstract override fun toString(): String

Properties

Link copied to clipboard
abstract val size: Int

The size of this buffer.

Inheritors

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Extensions

Link copied to clipboard
fun <T> Buffer<T>.asIterable(): Iterable<T>

Creates an iterable that returns all elements from this Buffer.

Link copied to clipboard
fun <T> Buffer<T>.asND(): Structure1D<T>

Represent this buffer as 1D structure

Link copied to clipboard
fun <T> Buffer<T>.asReadOnly(): Buffer<T>

Convert this buffer to read-only buffer.

Link copied to clipboard
fun <T> Buffer<T>.asSequence(): Sequence<T>

Creates a sequence that returns all elements from this Buffer.

Link copied to clipboard
open operator fun Buffer<Double>.div(arg: Buffer<Double>): Buffer<Double>

Division of two elements.

open operator fun Buffer<Double>.div(k: Number): Buffer<Double>

Division of this element by scalar.

Link copied to clipboard
fun <T> Buffer<T>.first(): T
Link copied to clipboard
inline fun <T : Any, R> Buffer<T>.fold(initial: R, operation: (R, T) -> R): R

Fold given buffer according to operation

Link copied to clipboard
val Buffer<*>.indices: IntRange

Returns an IntRange of the valid indices for this Buffer.

Link copied to clipboard
fun <V : Comparable<V>> Buffer<V>.indicesSorted(): IntArray

Return a new array filled with buffer indices. Indices order is defined by sorting associated buffer value. This feature allows sorting buffer values without reordering its content.

Link copied to clipboard
fun <V, C : Comparable<C>> Buffer<V>.indicesSortedBy(selector: (V) -> C): IntArray
Link copied to clipboard
fun <V, C : Comparable<C>> Buffer<V>.indicesSortedByDescending(selector: (V) -> C): IntArray
Link copied to clipboard
fun <V : Comparable<V>> Buffer<V>.indicesSortedDescending(): IntArray
Link copied to clipboard
fun <V> Buffer<V>.indicesSortedWith(comparator: Comparator<V>): IntArray
Link copied to clipboard
fun <T> Buffer<T>.last(): T
Link copied to clipboard
open override fun Buffer<Double>.map(block: DoubleField.(Double) -> Double): DoubleBuffer

inline fun <T : Any, R : Any> Buffer<T>.map(block: (T) -> R): Buffer<R>

Create a new buffer from this one with the given mapping function and using Buffer.Companion.auto buffer factory.

inline fun <T : Any, R : Any> Buffer<T>.map(bufferFactory: BufferFactory<R>, crossinline block: (T) -> R): Buffer<R>

Create a new buffer from this one with the given mapping function. Provided bufferFactory is used to construct the new buffer.

Link copied to clipboard
open fun Buffer<Double>.mapIndexed(block: DoubleField.(index: Int, arg: Double) -> Double): Buffer<Double>

inline fun <T : Any, R : Any> Buffer<T>.mapIndexed(bufferFactory: BufferFactory<R> = Buffer.Companion::auto, crossinline block: (index: Int, T) -> R): Buffer<R>

Create a new buffer from this one with the given indexed mapping function. Provided BufferFactory is used to construct the new buffer.

Link copied to clipboard
inline fun Buffer<Double>.mapInline(block: (Double) -> Double): DoubleBuffer
Link copied to clipboard
open operator override fun Buffer<Double>.minus(arg: Buffer<Double>): DoubleBuffer

Subtraction of two elements.

Link copied to clipboard
open operator override fun Buffer<Double>.plus(arg: Buffer<Double>): DoubleBuffer

Addition of two elements.

Link copied to clipboard
fun <T : Comparable<T>> Buffer<T>.requireSorted()

Checks that the Buffer is sorted (ascending) and throws IllegalArgumentException if it is not.

Link copied to clipboard
fun <V : Comparable<V>> Buffer<V>.sorted(): Buffer<V>

Create a zero-copy virtual buffer that contains the same elements but in ascending order

Link copied to clipboard
fun <V, C : Comparable<C>> Buffer<V>.sortedBy(selector: (V) -> C): Buffer<V>
Link copied to clipboard
fun <V, C : Comparable<C>> Buffer<V>.sortedByDescending(selector: (V) -> C): Buffer<V>
Link copied to clipboard
fun <V : Comparable<V>> Buffer<V>.sortedDescending(): Buffer<V>

Create a zero-copy virtual buffer that contains the same elements but in descending order

Link copied to clipboard
open operator fun Buffer<Double>.times(arg: Buffer<Double>): Buffer<Double>

Multiplies this element by scalar.

open operator fun Buffer<Double>.times(k: Number): Buffer<Double>

Multiplication of this element by a scalar.

Link copied to clipboard
fun Buffer<Double>.toDoubleArray(): DoubleArray

Returns a new DoubleArray containing all the elements of this Buffer.

Link copied to clipboard
fun Buffer<Float>.toFloatArray(): FloatArray

Returns a new FloatArray containing all the elements of this Buffer.

Link copied to clipboard
fun Buffer<Int>.toIntArray(): IntArray

Returns a new IntArray containing all the elements of this Buffer.

Link copied to clipboard
fun <T> Buffer<T>.toList(): List<T>

Returns a new List containing all elements of this buffer.

Link copied to clipboard
fun Buffer<Long>.toLongArray(): LongArray

Returns a new LongArray containing all the elements of this Buffer.

Link copied to clipboard
fun <T> Buffer<T>.toMutableList(): MutableList<T>

Returns a new MutableList filled with all elements of this buffer. NOTE: this method uses a protective copy, so it should not be used in performance-critical code.

Link copied to clipboard
fun Buffer<Short>.toShortArray(): ShortArray

Returns a new ShortArray containing all the elements of this Buffer.

Link copied to clipboard
inline fun <T> Buffer<T>.toTypedArray(): Array<T>

Returns a new Array containing all elements of this buffer. NOTE: this method uses a protective copy, so it should not be used in performance-critical code.

Link copied to clipboard
open operator override fun Buffer<Double>.unaryMinus(): DoubleBuffer

The negation of this element.

Link copied to clipboard
open operator fun Buffer<Double>.unaryPlus(): Buffer<Double>

Returns this value.

Link copied to clipboard
open fun Buffer<Double>.zip(other: Buffer<Double>, block: DoubleField.(left: Double, right: Double) -> Double): Buffer<Double>

inline fun <T1 : Any, T2 : Any, R : Any> Buffer<T1>.zip(other: Buffer<T2>, bufferFactory: BufferFactory<R> = Buffer.Companion::auto, crossinline transform: (T1, T2) -> R): Buffer<R>

Zip two buffers using given transform.

Sources

Link copied to clipboard