Class FindCommonVoxelType

Object
FindCommonVoxelType

public class FindCommonVoxelType extends Object
Finds a common voxel-data type to represent two types.

This usually either the class themselves or a type that is minimally larger, and can represent both types without loss of precision.

An exception is the float-type that takes precedence over all others, and this may lead to loss of precision.

Author:
Owen Feehan
  • Method Details

    • commonType

      public static Optional<VoxelDataType> commonType(Stream<VoxelDataType> stream)
      Finds a common type to represent (ideally without loss of precision} of a stream of types.
      Parameters:
      stream - a stream of types to find a common representation for.
      Returns:
      a type that can represent all types (think of it as a minimal superset of all types), or Optional.empty() if the stream has no elements.
    • commonType

      public static VoxelDataType commonType(VoxelDataType first, VoxelDataType second)
      Finds a common type to represent (ideally without loss of precision} both first and second.
      Parameters:
      first - the first-type that must be represented in the common type
      second - the second-type that must be represented in the common type
      Returns:
      a type that can represent both (think of it as a minimal superset of both types).