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.
  • Method Details

    • mut_replace

      MutSelf mut_replace(double magnitude, U newUnit)
      Overwrites the state of this measure with new values.
      Parameters:
      magnitude - the new magnitude in terms of the new unit
      newUnit - the new unit
      Returns:
      this measure
    • mut_replace

      default MutSelf mut_replace(Base other)
      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 calling other.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.
      Specified by:
      copy in interface Measure<U extends Unit>
      Returns:
      the copied measure
    • mut_setMagnitude

      default MutSelf mut_setMagnitude(double magnitude)
      Sets the new magnitude of the measurement. The magnitude must be in terms of the Measure.unit().
      Parameters:
      magnitude - the new magnitude of the measurement
      Returns:
      this mutable measure
    • mut_setBaseUnitMagnitude

      default MutSelf mut_setBaseUnitMagnitude(double baseUnitMagnitude)
      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

      default MutSelf mut_acc(double raw)
      Increments the current magnitude of the measure by the given value. The value must be in terms of the current unit.
      Parameters:
      raw - the raw value to accumulate by
      Returns:
      the measure
    • mut_acc

      default MutSelf mut_acc(Base other)
      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

      default MutSelf mut_plus(Base other)
      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

      default MutSelf mut_plus(double magnitude, U otherUnit)
      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(Measure) to avoid having to wrap raw numbers in a Measure 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

      default MutSelf mut_minus(Base other)
      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

      default MutSelf mut_minus(double magnitude, U otherUnit)
      Subtracts another measurement from this one. This will mutate the object instead of generating a new measurement object. This is a denormalized version of mut_minus(Measure) to avoid having to wrap raw numbers in a Measure 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

      default MutSelf mut_times(double multiplier)
      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

      default MutSelf mut_times(Dimensionless multiplier)
      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

      default MutSelf mut_divide(double divisor)
      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

      default MutSelf mut_divide(Dimensionless divisor)
      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