commonMain.Arguments.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of selection Show documentation
Show all versions of selection Show documentation
A collection of drawing/charting utilities
The newest version!
package com.juul.krayon.selection
/**
* Wrapper around d3's standard argument order. This helps serve as syntax sugar for their style of overloading,
* where you often don't use the arguments at all, or only bind the first one or two.
*
* Library consumers should not hold on to instances of this class, it is internally mutated heavily as an optimization.
*/
public class Arguments private constructor(
datum: D,
index: Int,
data: List,
) {
public var datum: D = datum
internal set
public var index: Int = index
internal set
public var data: List = data
internal set
public operator fun component1(): D = datum
public operator fun component2(): Int = index
public operator fun component3(): List = data
@PublishedApi
internal class Buffer {
private val arguments = Arguments(null, -1, listOf())
operator fun invoke(datum: D, index: Int, data: List): Arguments {
arguments.datum = datum
arguments.index = index
arguments.data = data
return arguments as Arguments
}
}
}