Class KDTreeData<T>

  • Type Parameters:
    T - the type of values stored in the tree.

    public class KDTreeData<T>
    extends java.lang.Object
    Stores the KDTree data, that is, positions and values.

    Positions are stored in either FLAT or NESTED layout. With NESTED layout, positions are stored as a nested double[][] array where positions[d][i] is dimension d of the i-th point. With FLAT layout, positions are stored as a flat double[] array, where positions[d + i*n] is dimension d of the i-th point, with n the number of dimensions.

    Values (of type T) are stored as either a 1D RandomAccessibleInterval<T>, or a List<T>. Individual values can be accessed by valuesSupplier().get().apply(i). valueSupplier().get() returns a reusable IntFunction<T>. Here T maybe a proxy that is reused in subsequent apply(i).

    values() returns all values as a 1D RandomAccessibleInterval<T>. (If data is stored as List<T>, it is wrapped into a ListImg.)

    • Field Detail

      • valuesSupplier

        private final java.util.function.Supplier<java.util.function.IntFunction<T>> valuesSupplier
      • type

        private final T type
    • Method Detail

      • getType

        public T getType()
      • values

        public RandomAccessibleInterval<T> values()
        Get the values as a 1D RandomAccessibleInterval, for serialization. (If the underlying storage is a List<T>, it will be wrapped as a ListImg.)
      • valuesSupplier

        public java.util.function.Supplier<java.util.function.IntFunction<T>> valuesSupplier()
        Get a Supplier that return IntFunction<T> to provide values for a given node indices. If the returned IntFunction<T> is stateful (T maybe a proxy that is reused in subsequent apply(i)} every Supplier.get() creates a new instance of the IntFunction<T>.
      • create

        public static <L extends RealLocalizable,​T> KDTreeData<T> create​(int numPoints,
                                                                               java.lang.Iterable<T> values,
                                                                               java.lang.Iterable<L> positions,
                                                                               boolean storeValuesAsNativeImg)
        Create KDTreeData from the given values and positions). (copies positions and sorts into a KDTree structure).
        Parameters:
        numPoints - number of points (number of elements in values and positions).
        values - values associated with points
        positions - points positions
        storeValuesAsNativeImg - If true and T is a NativeType, store values into NativeImg. Otherwise, store values as a List<T>.