Refactor names for AttributesBuilder behavior
This commit is contained in:
parent
1be6a5ca0e
commit
461e5a7c54
@ -84,7 +84,7 @@ public fun <A : Attribute<Unit>> Attributes.withAttribute(attribute: A): Attribu
|
||||
* Create a new [Attributes] by modifying the current one
|
||||
*/
|
||||
public fun <T> Attributes.modify(block: AttributesBuilder<T>.() -> Unit): Attributes = Attributes<T> {
|
||||
from(this@modify)
|
||||
putAll(this@modify)
|
||||
block()
|
||||
}
|
||||
|
||||
|
@ -34,13 +34,18 @@ public class AttributesBuilder<out O> internal constructor(
|
||||
set(this, value)
|
||||
}
|
||||
|
||||
public fun from(attributes: Attributes) {
|
||||
public infix fun <V> Attribute<V>.put(value: V?) {
|
||||
set(this, value)
|
||||
}
|
||||
|
||||
/**
|
||||
* Put all attributes for given [attributes]
|
||||
*/
|
||||
public fun putAll(attributes: Attributes) {
|
||||
map.putAll(attributes.content)
|
||||
}
|
||||
|
||||
public fun <V> SetAttribute<V>.add(
|
||||
attrValue: V,
|
||||
) {
|
||||
public infix fun <V> SetAttribute<V>.add(attrValue: V) {
|
||||
val currentSet: Set<V> = get(this) ?: emptySet()
|
||||
map[this] = currentSet + attrValue
|
||||
}
|
||||
@ -48,9 +53,7 @@ public class AttributesBuilder<out O> internal constructor(
|
||||
/**
|
||||
* Remove an element from [SetAttribute]
|
||||
*/
|
||||
public fun <V> SetAttribute<V>.remove(
|
||||
attrValue: V,
|
||||
) {
|
||||
public infix fun <V> SetAttribute<V>.remove(attrValue: V) {
|
||||
val currentSet: Set<V> = get(this) ?: emptySet()
|
||||
map[this] = currentSet - attrValue
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ public object CMOptimizerData : SetAttribute<SymbolIndexer.() -> OptimizationDat
|
||||
* Specify Commons-maths optimization data.
|
||||
*/
|
||||
public fun AttributesBuilder<FunctionOptimization<Double>>.cmOptimizationData(data: SymbolIndexer.() -> OptimizationData) {
|
||||
CMOptimizerData.add(data)
|
||||
CMOptimizerData add data
|
||||
}
|
||||
|
||||
public fun AttributesBuilder<FunctionOptimization<Double>>.simplexSteps(vararg steps: Pair<Symbol, Double>) {
|
||||
|
Loading…
Reference in New Issue
Block a user