MutableMeasure

class MutableMeasure<U : Unit<U>?> : Measure<U>

A specialization of Measure that allows for mutability. This is intended to be used for memory use reasons (such as on the memory-restricted roboRIO 1 or 2 or SBC coprocessors) and should NOT be exposed in the public API for a class that uses it.

The advantage of using this class is to reuse one instance of a measurement object, as opposed to instantiating a new immutable instance every time an operation is performed. This will reduce memory pressure, but comes at the cost of increased code complexity and sensitivity to race conditions if misused.

Any unsafe methods are prefixed with mut_*, such as mut_plus or mut_replace. These methods will change the internal state of the measurement object, and as such can be dangerous to use. They are primarily intended for use to track internal state of things like sensors

Since

1.0.0-pre

Parameters

<U>

the type of the unit of measure

Inherited properties

Link copied to clipboard
The threshold for two measures to be considered equivalent if converted to the same unit.

Functions

Link copied to clipboard
Gets the magnitude of this measure in terms of the base unit.
Link copied to clipboard
open fun copy(): Measure<U>
Returns an immutable copy of this measure.
Link copied to clipboard
open fun equals(o: Any): Boolean
Link copied to clipboard
open fun hashCode(): Int
Link copied to clipboard
open fun magnitude(): Double
Gets the unitless magnitude of this measure.
Link copied to clipboard
open fun mut_acc(raw: Double): MutableMeasure<U>
Increments the current magnitude of the measure by the given value.
open fun mut_acc(other: Measure<U>): MutableMeasure<U>
Increments the current magnitude of the measure by the amount of the given measure.
Link copied to clipboard
open fun mut_divide(divisor: Double): MutableMeasure<U>
open fun mut_divide(divisor: Measure<out Dimensionless>): MutableMeasure<U>
Divides this measurement by some constant value.
Link copied to clipboard
open fun mut_minus(other: Measure<U>): MutableMeasure<U>
open fun mut_minus(magnitude: Double, unit: U): MutableMeasure<U>
Subtracts another measurement to this one.
Link copied to clipboard
open fun mut_plus(other: Measure<U>): MutableMeasure<U>
open fun mut_plus(magnitude: Double, unit: U): MutableMeasure<U>
Adds another measurement to this one.
Link copied to clipboard
open fun mut_replace(other: Measure<U>): MutableMeasure<U>
Overwrites the state of this measure and replaces it with values from the given one.
open fun mut_replace(magnitude: Double, unit: U): MutableMeasure<U>
Overwrites the state of this measure with new values.
Link copied to clipboard
open fun mut_setBaseUnitMagnitude(baseUnitMagnitude: Double)
Sets the new magnitude of the measurement.
Link copied to clipboard
open fun mut_setMagnitude(magnitude: Double)
Sets the new magnitude of the measurement.
Link copied to clipboard
open fun mut_times(multiplier: Double): MutableMeasure<U>
open fun mut_times(multiplier: Measure<out Dimensionless>): MutableMeasure<U>
Multiplies this measurement by some constant value.
Link copied to clipboard
open fun <U : Unit<U>?> mutable(measure: Measure<U>): MutableMeasure<U>
Creates a new mutable measure that is a copy of the given one.
Link copied to clipboard
open fun <U : Unit<U>?> ofBaseUnits(baseUnitMagnitude: Double, unit: U): MutableMeasure<U>
Creates a new mutable measure in the given unit with a magnitude equal to the given one in base units.
Link copied to clipboard
open fun <U : Unit<U>?> ofRelativeUnits(relativeMagnitude: Double, unit: U): MutableMeasure<U>
Creates a new mutable measure in the given unit with a magnitude in terms of that unit.
Link copied to clipboard
open fun toString(): String
Link copied to clipboard
open fun unit(): U
Gets the units of this measure.
Link copied to clipboard
open fun <U : Unit<U>?> zero(unit: U): MutableMeasure<U>
Creates a new mutable measure with a magnitude of 0 in the given unit.

Inherited functions

Link copied to clipboard
abstract fun compareTo(p: T): Int
open fun compareTo(o: Measure<U>): Int
Link copied to clipboard
open fun divide(divisor: Double): Measure<U>
Divides this measurement by some constant divisor and returns the result.
open fun <U2 : Unit<U2>?> divide(other: Measure<U2>): Measure<out Any>
Divides this measurement by another measure and performs some dimensional analysis to reduce the units.
Link copied to clipboard
open fun gt(o: Measure<U>): Boolean
Checks if this measure is greater than another measure of the same unit.
Link copied to clipboard
open fun gte(o: Measure<U>): Boolean
Checks if this measure is greater than or equivalent to another measure of the same unit.
Link copied to clipboard
open fun in(unit: Unit<U>): Double
Converts this measure to a measure with a different unit of the same type, eg minutes to seconds.
Link copied to clipboard
open fun inUnit(unit: Unit<U>): Double
Converts this measure to a measure with a different unit of the same type, eg minutes to seconds.
Link copied to clipboard
open fun isEquivalent(other: Measure<out Any>): Boolean
Checks if this measure is equivalent to another measure of the same unit.
Link copied to clipboard
open fun isNear(other: Measure<out Any>, varianceThreshold: Double): Boolean
Checks if this measure is near another measure of the same unit.
open fun isNear(other: Measure<U>, tolerance: Measure<U>): Boolean
Checks if this measure is near another measure of the same unit, with a specified tolerance of the same unit.
Link copied to clipboard
open fun lt(o: Measure<U>): Boolean
Checks if this measure is less than another measure of the same unit.
Link copied to clipboard
open fun lte(o: Measure<U>): Boolean
Checks if this measure is less than or equivalent to another measure of the same unit.
Link copied to clipboard
open fun <U : Unit<U>?> max(measures: Array<Measure<U>>): Measure<U>
Returns the measure with the absolute value closest to positive infinity.
Link copied to clipboard
open fun <U : Unit<U>?> min(measures: Array<Measure<U>>): Measure<U>
Returns the measure with the absolute value closest to negative infinity.
Link copied to clipboard
open fun minus(other: Measure<U>): Measure<U>
Subtracts another measure from this one.
Link copied to clipboard
Creates a new mutable copy of this measure.
Link copied to clipboard
open fun negate(): Measure<U>
Negates this measure and returns the result.
Link copied to clipboard
open fun <U2 : Unit<U2>?> per(denominator: U2): Measure<Per<U, U2>>
Creates a relational measure equivalent to this one per some other unit.
open fun per(period: Measure<Time>): Measure<Velocity<U>>
Creates a velocity measure by dividing this one by a time period measure.
open fun per(time: Time): Measure<Velocity<U>>
Creates a velocity measure equivalent to this one per a unit of time.
Link copied to clipboard
open fun plus(other: Measure<U>): Measure<U>
Adds another measure to this one.
Link copied to clipboard
open fun times(multiplier: Double): Measure<U>
Multiplies this measurement by some constant multiplier and returns the result.
open fun <U2 : Unit<U2>?> times(other: Measure<U2>): Measure<out Any>
Generates a new measure that is equal to this measure multiplied by another.
Link copied to clipboard
open fun toLongString(): String
Returns a string representation of this measurement in a longhand form.
Link copied to clipboard
Returns a string representation of this measurement in a scientific shorthand form.
Link copied to clipboard
open fun toShortString(): String
Returns a string representation of this measurement in the default form.