Class GridArrays


  • public final class GridArrays
    extends Object
    Utility methods to work with arrays.
    • Method Detail

      • set

        public static <T> T[] set​(T[] arr,
                                  int idx,
                                  T o)
        Set element to the array at the given index. Grows the array if needed.
        Parameters:
        arr - Array.
        idx - Index.
        o - Object.
        Returns:
        The given or grown array.
      • remove

        public static <T> T[] remove​(T[] arr,
                                     int idx)
        Parameters:
        arr - Array.
        idx - Index to remove.
        Returns:
        Smaller array.
      • remove

        public static long[] remove​(long[] arr,
                                    int idx)
        Parameters:
        arr - Array.
        idx - Index to remove.
        Returns:
        Smaller array.
      • clearTail

        public static void clearTail​(Object[] arr,
                                     int fromIdx)
        Nullify array elements from the given index until the first null element (assuming that after the first null tail is already cleared).
        Parameters:
        arr - Array.
        fromIdx - From index (including).