Class UnitFactors


  • public class UnitFactors
    extends java.lang.Object
    Build a graph of conversion factors between units. Sets of conversion factors are closed, e.g. any factor must be convertable into any other unit in the set. Their must be a connected path of length 1 or greater between any two units. Gaps in the graph represent conversion factors that are unknown at the time of graph construction. These are incrementally filled in on demand by finding the shortest and lowest-cost conversion path between two units with no direct conversion factor. The path is transformed into a direct conversion factor by multiplying all factors along the path. Finally the new factor is added to the graph.
    • Constructor Summary

      Constructors 
      Constructor Description
      UnitFactors​(java.util.List<FactorDef> factors)  
      UnitFactors​(java.util.List<FactorDef> factors, boolean memoize)
      Build a unit converter graph using the given factors.
    • Field Detail

      • unitset

        public final java.util.Set<UnitType> unitset
      • units

        public final java.util.List<UnitType> units
    • Constructor Detail

      • UnitFactors

        public UnitFactors​(java.util.List<FactorDef> factors)
      • UnitFactors

        public UnitFactors​(java.util.List<FactorDef> factors,
                           boolean memoize)
        Build a unit converter graph using the given factors.
    • Method Detail

      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object