Class IntervalVolume.Builder

  • Enclosing class:
    IntervalVolume

    public static final class IntervalVolume.Builder
    extends Object
    A builder of immutable IntervalVolumes.

    Rows, columns, and levels must be specified before any data can be added. Note that any supplied max values may not correspond to the final upper edge of the uppermost bins if max - min is not evenly divisible by Δ.

    • Constructor Detail

      • Builder

        public Builder()
        Create a new interval volume builder.
    • Method Detail

      • copyOf

        public static IntervalVolume.Builder copyOf​(IntervalVolume volume)
        Create a new builder with the structure and content identical to that of the supplied volume.
        Parameters:
        volume - to copy
      • fromModel

        public static IntervalVolume.Builder fromModel​(IntervalVolume model)
        Create a new builder with a structure identical to that of the supplied model.
        Parameters:
        model - data volume
      • rows

        public IntervalVolume.Builder rows​(double min,
                                           double max,
                                           double delta)
        Define the data volume rows.
        Parameters:
        min - lower edge of lowermost row bin
        max - upper edge of uppermost row bin
        delta - bin discretization
      • columns

        public IntervalVolume.Builder columns​(double min,
                                              double max,
                                              double delta)
        Define the data volume columns.
        Parameters:
        min - lower edge of lowermost column bin
        max - upper edge of uppermost column bin
        delta - bin discretization
      • levels

        public IntervalVolume.Builder levels​(double min,
                                             double max,
                                             double delta)
        Define the data volume levels.
        Parameters:
        min - lower edge of lowermost column bin
        max - upper edge of uppermost column bin
        delta - bin discretization
      • rowIndex

        public int rowIndex​(double row)
        Return the index of the row that would contain the supplied value.
        Parameters:
        row - value
      • columnIndex

        public int columnIndex​(double column)
        Return the index of the column that would contain the supplied value.
        Parameters:
        column - value
      • levelIndex

        public int levelIndex​(double level)
        Return the index of the level that would contain the supplied value.
        Parameters:
        level - value
      • set

        public IntervalVolume.Builder set​(double row,
                                          double column,
                                          double level,
                                          double value)
        Set the value at the specified row, column, and level. Be careful not to confuse this with set(int, int, int, double).
        Parameters:
        row - key
        column - key
        level - key
        value - to set
      • set

        public IntervalVolume.Builder set​(int row,
                                          int column,
                                          int level,
                                          double value)
        Set the value at the specified row, column, and level indices. Be careful not to confuse this with set(double, double, double, double).
        Parameters:
        row - index
        column - index
        level - index
        value - to set
      • add

        public IntervalVolume.Builder add​(double row,
                                          double column,
                                          double level,
                                          double value)
        Add to the existing value at the specified row, column, and level. Be careful not to confuse this with add(int, int, int, double).
        Parameters:
        row - key
        column - key
        level - key
        value - to add
      • add

        public IntervalVolume.Builder add​(int row,
                                          int column,
                                          int level,
                                          double value)
        Add to the existing value at the specified row, column, and level indices. Be careful not to confuse this with add(double, double, double, double).
        Parameters:
        row - index
        column - index
        level - index
        value -
      • add

        public IntervalVolume.Builder add​(double row,
                                          double column,
                                          double[] values)
        Add to the level array at the specified row and column. Assumes that supplied value array is the same size or smaller than the levels of the internal builder data array.
        Parameters:
        row - key
        column - key
        values - to add
        Throws:
        IndexOutOfBoundsException - if values overrun level
      • add

        public IntervalVolume.Builder add​(double row,
                                          double column,
                                          XySequence sequence)
        Add the y-values of the supplied sequence to the level array at the specified row and column. Assumes that supplied sequence is the same size or smaller than the levels of the internal builder data array.
        Parameters:
        row - key
        column - key
        sequence - to add
        Throws:
        IndexOutOfBoundsException - if values overrun level
      • add

        public IntervalVolume.Builder add​(IntervalVolume volume)
        Add the values in the supplied interval volume to this builder. This operation is very efficient if this builder and the supplied volume are sourced from the same model.
        Parameters:
        volume - to add
        Throws:
        IllegalArgumentException - if the rows, columns, and levels of the supplied volume do not match those of this volume
        See Also:
        fromModel(IntervalVolume)
      • multiply

        public IntervalVolume.Builder multiply​(double scale)
        Multiply (scale) all values in this builder.
        Parameters:
        scale - factor
      • build

        public IntervalVolume build()
        Return a newly-created, immutable 3-dimensional interval data container populated with the contents of this Builder.