Mutable Measure
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
Functions
Gets the magnitude of this measure in terms of the base unit. If the unit is the base unit for its system of measure, then the value will be equivalent to magnitude.
Increments the current magnitude of the measure by the amount of the given measure.
Increments the current magnitude of the measure by the given value. The value must be in terms of the current unit.
Divides this measurement by some constant value. This will mutate the object instead of generating a new measurement object.
Subtracts another measurement to this one. This will mutate the object instead of generating a new measurement object.
Subtracts another measurement to this one. This will mutate the object instead of generating a new measurement object. This is a denormalized version of mut_minus to avoid having to wrap raw numbers in a Measure
object and pay for an object allocation.
Adds another measurement to this one. This will mutate the object instead of generating a new measurement object.
Adds another measurement to this one. This will mutate the object instead of generating a new measurement object. This is a denormalized version of mut_plus to avoid having to wrap raw numbers in a Measure
object and pay for an object allocation.
Overwrites the state of this measure and replaces it with values from the given one.
Overwrites the state of this measure with new values.
Sets the new magnitude of the measurement. The magnitude must be in terms of the base unit of the current unit.
Sets the new magnitude of the measurement. The magnitude must be in terms of the unit.
Multiplies this measurement by some constant value. This will mutate the object instead of generating a new measurement object.
Inherited functions
Divides this measurement by another measure and performs some dimensional analysis to reduce the units.
Divides this measurement by some constant divisor and returns the result. This is equivalent to times(1 / divisor)
Checks if this measure is equivalent to another measure of the same unit.
Checks if this measure is near another measure of the same unit. Provide a variance threshold for use for a +/- scalar, such as 0.05 for +/- 5%.
Checks if this measure is near another measure of the same unit, with a specified tolerance of the same unit.
Creates a new mutable copy of this measure.
Creates a relational measure equivalent to this one per some other unit.
Creates a velocity measure by dividing this one by a time period measure.
Creates a velocity measure equivalent to this one per a unit of time.
Generates a new measure that is equal to this measure multiplied by another. Some dimensional analysis is performed to reduce the units down somewhat; for example, multiplying a Measure<Time>
by a Measure<Velocity<Distance>>
will return just a Measure<Distance>
instead of the naive Measure<Mult<Time, Velocity<Distance>>
. This is not guaranteed to perform perfect dimensional analysis.
Multiplies this measurement by some constant multiplier and returns the result. The magnitude of the result will be the base magnitude multiplied by the scalar value. If the measure uses a unit with a non-linear relation to its base unit (such as Fahrenheit for temperature), then the result will only be a multiple in terms of the base unit.
Returns a string representation of this measurement in a longhand form. The name of the backing unit is used, rather than its symbol, and the magnitude is represented in a full string, not scientific notation. (Very large values may be represented in scientific notation, however)
Returns a string representation of this measurement in a scientific shorthand form. The symbol of the backing unit is used, rather than the full name, and the magnitude is represented in scientific notation.
Returns a string representation of this measurement in the default form. The symbol of the backing unit is used, rather than the full name, and the magnitude is represented in full, not in scientific notation. (Very large values may be represented in scientific notation, however)
Negates this measure and returns the result.