scroll static method

void scroll(
  1. List<Coordinate> coordinates,
  2. Coordinate firstCoordinate
)

Shifts the positions of the coordinates until firstCoordinate is first.

@param coordinates the array to rearrange @param firstCoordinate the coordinate to make first

Implementation

static void scroll(List<Coordinate> coordinates, Coordinate firstCoordinate) {
  int i = coordinates.indexOf(firstCoordinate);
  if (i < 0) return;

  var newCoordinates = CollectionsUtils.shiftToFirst(coordinates, i)!;
  coordinates.clear();
  coordinates.addAll(newCoordinates);
}