Class ToNaN

All Implemented Interfaces:
Serializable, Cloneable, Iterable<Integer>, Collection<Integer>, DoubleToIntFunction, Set<Integer>

final class ToNaN extends HashSet<Integer> implements DoubleToIntFunction
Keep trace of allocated Float.NaN ordinal values for avoiding range collisions when building categories. This is a temporary object used only at SampleDimension construction time for producing values suitable to MathFunctions.toNanFloat(int). Instances of this class are given for toNaN argument in the Category constructor.
Since:
1.0
Version:
1.1
  • Field Details

    • background

      Number background
      The value which should be assigned ordinal 0 if that ordinal value is available. For performance reason, the background value should be assigned ordinal 0 when possible. This is null if unspecified.
  • Constructor Details

    • ToNaN

      ToNaN()
      To be constructed only from this package.
  • Method Details

    • clear

      public void clear()
      Sets this function to the same state than after construction. This method is invoked when the same builder is reused for creating many sample dimensions.
      Specified by:
      clear in interface Collection<Integer>
      Specified by:
      clear in interface Set<Integer>
      Overrides:
      clear in class HashSet<Integer>
    • isBackground

      private boolean isBackground(double value)
      Returns true if the specified value is the background value.
    • applyAsInt

      public int applyAsInt(double value)
      Mapping from sample values to ordinal values to be supplied to MathFunctions.toNanFloat(int). That mapping shall ensure that there are no ordinal value collisions between different categories in the same SampleDimension.
      Specified by:
      applyAsInt in interface DoubleToIntFunction
      Parameters:
      value - a real number in the Category.range sample value range.
      Returns:
      a value between -2097152 and 2097151 inclusive.
    • remove

      void remove(Category c)
      Removes the NaN value which has been reserved for a qualitative category. This method does nothing if converted is not a NaN value, i.e. if the category is quantitative instead of qualitative.
      Parameters:
      c - the presumed qualitative category.