class GridInfo {

  static int getIndex(int[] lineLocations, int location, boolean skipEqualLineLocations) {
    if (lineLocations.length < 2) {
      throw new IllegalArgumentException(Arrays.toString(lineLocations));
    }
    else if (location < lineLocations[0] || location > lineLocations[lineLocations.length - 1]) {
      return -1;
    }

    for (int i = 0, j = 0; i < lineLocations.length - 1; i++) {
      if (skipEqualLineLocations && lineLocations[i] == lineLocations[i + 1]) {
        continue;
      }

      if (lineLocations[i] <= location && location < lineLocations[i + 1]) {
        return j;
      }

      // noinspection AssignmentToForLoopParameter
      j++;
    }

    throw new AssertionError();
  }

    GridInfo(NlComponent layout);

}