Package edu.wpi.first.units
Interface MutableMeasure<U extends Unit,Base extends Measure<U>,MutSelf extends MutableMeasure<U,Base,MutSelf>>
- Type Parameters:
U
- The dimension of measurement.Base
- The base measure type.MutSelf
- The self type. This MUST inherit from the base measure type.
- All Superinterfaces:
Comparable<Measure<U>>
,Measure<U>
- All Known Implementing Classes:
GenericMutableMeasureImpl
,MutableMeasureBase
,MutAcceleration
,MutAngle
,MutAngularAcceleration
,MutAngularMomentum
,MutAngularVelocity
,MutCurrent
,MutDimensionless
,MutDistance
,MutEnergy
,MutForce
,MutFrequency
,MutLinearAcceleration
,MutLinearMomentum
,MutLinearVelocity
,MutMass
,MutMomentOfInertia
,MutMult
,MutPer
,MutPower
,MutResistance
,MutTemperature
,MutTime
,MutTorque
,MutVelocity
,MutVoltage
public interface MutableMeasure<U extends Unit,Base extends Measure<U>,MutSelf extends MutableMeasure<U,Base,MutSelf>>
extends Measure<U>
A mutable measurement can be used to keep a single object allocation and reference whose state is
mutated or changed as it is used. This is helpful for optimizing memory usage to keep garbage
collection time - and its associated loop overruns - to a minimum.
-
Field Summary
Fields inherited from interface edu.wpi.first.units.Measure
EQUIVALENCE_THRESHOLD
-
Method Summary
Modifier and TypeMethodDescriptioncopy()
Returns an immutable copy of this measure.default MutSelf
mut_acc
(double raw) Increments the current magnitude of the measure by the given value.default MutSelf
Increments the current magnitude of the measure by the amount of the given measure.default MutSelf
mut_divide
(double divisor) Divides this measurement by some constant value.default MutSelf
mut_divide
(Dimensionless divisor) Divides this measurement by some constant value.default MutSelf
Subtracts another measurement from this one.default MutSelf
Subtracts another measurement to this one.default MutSelf
Adds another measurement to this one.default MutSelf
Adds another measurement to this one.mut_replace
(double magnitude, U newUnit) Overwrites the state of this measure with new values.default MutSelf
mut_replace
(Base other) Overwrites the state of this measure and replaces it completely with values from the given one.default MutSelf
mut_setBaseUnitMagnitude
(double baseUnitMagnitude) Sets the new magnitude of the measurement.default MutSelf
mut_setMagnitude
(double magnitude) Sets the new magnitude of the measurement.default MutSelf
mut_times
(double multiplier) Multiplies this measurement by some constant value.default MutSelf
mut_times
(Dimensionless multiplier) Multiplies this measurement by some constant value.Methods inherited from interface edu.wpi.first.units.Measure
abs, baseUnit, baseUnitMagnitude, compareTo, copySign, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, div, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divide, divideRatio, gt, gte, in, isEquivalent, isNear, isNear, lt, lte, magnitude, minus, mutableCopy, negate, per, plus, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, times, timesConversionFactor, timesInverse, timesRatio, toLongString, toShortString, unaryMinus, unit
-
Method Details
-
mut_replace
Overwrites the state of this measure with new values.- Parameters:
magnitude
- the new magnitude in terms of the new unitnewUnit
- the new unit- Returns:
- this measure
-
mut_replace
Overwrites the state of this measure and replaces it completely with values from the given one. The magnitude, base unit magnitude, and unit will all be copied. This is functionally the same as callingother.mutableCopy()
, but copying to a pre-existing mutable measure instead of instantiating a new one.- Parameters:
other
- the other measure to copy values from- Returns:
- this measure
-
copy
Description copied from interface:Measure
Returns an immutable copy of this measure. The copy can be used freely and is guaranteed never to change. -
mut_setMagnitude
Sets the new magnitude of the measurement. The magnitude must be in terms of theMeasure.unit()
.- Parameters:
magnitude
- the new magnitude of the measurement- Returns:
- this mutable measure
-
mut_setBaseUnitMagnitude
Sets the new magnitude of the measurement. The magnitude must be in terms of the base unit of the current unit.- Parameters:
baseUnitMagnitude
- the new magnitude of the measurement- Returns:
- this mutable measure
-
mut_acc
Increments the current magnitude of the measure by the given value. The value must be in terms of the currentunit
.- Parameters:
raw
- the raw value to accumulate by- Returns:
- the measure
-
mut_acc
Increments the current magnitude of the measure by the amount of the given measure.- Parameters:
other
- the measure whose value should be added to this one- Returns:
- this measure
-
mut_plus
Adds another measurement to this one. This will mutate the object instead of generating a new measurement object.- Parameters:
other
- the measurement to add- Returns:
- this measure
-
mut_plus
Adds another measurement to this one. This will mutate the object instead of generating a new measurement object. This is a denormalized version ofmut_plus(Measure)
to avoid having to wrap raw numbers in aMeasure
object and pay for an object allocation.- Parameters:
magnitude
- the magnitude of the other measurement.otherUnit
- the unit of the other measurement- Returns:
- this measure
-
mut_minus
Subtracts another measurement to this one. This will mutate the object instead of generating a new measurement object.- Parameters:
other
- the measurement to subtract from this one- Returns:
- this measure
-
mut_minus
Subtracts another measurement from this one. This will mutate the object instead of generating a new measurement object. This is a denormalized version ofmut_minus(Measure)
to avoid having to wrap raw numbers in aMeasure
object and pay for an object allocation.- Parameters:
magnitude
- the magnitude of the other measurement.otherUnit
- the unit of the other measurement- Returns:
- this measure
-
mut_times
Multiplies this measurement by some constant value. This will mutate the object instead of generating a new measurement object.- Parameters:
multiplier
- the multiplier to scale the measurement by- Returns:
- this measure
-
mut_times
Multiplies this measurement by some constant value. This will mutate the object instead of generating a new measurement object.- Parameters:
multiplier
- the multiplier to scale the measurement by- Returns:
- this measure
-
mut_divide
Divides this measurement by some constant value. This will mutate the object instead of generating a new measurement object.- Parameters:
divisor
- the divisor to scale the measurement by- Returns:
- this measure
-
mut_divide
Divides this measurement by some constant value. This will mutate the object instead of generating a new measurement object.- Parameters:
divisor
- the divisor to scale the measurement by- Returns:
- this measure
-