removeNull static method
Collapses a coordinate array to remove all null elements.
@param coord the coordinate array to collapse @return an array containing only non-null elements
Implementation
static List<Coordinate> removeNull(List<Coordinate?> coord) {
int nonNull = 0;
for (int i = 0; i < coord.length; i++) {
if (coord[i] != null) nonNull++;
}
List<Coordinate> newCoord = []; //..length = (nonNull);
// empty case
if (nonNull == 0) return newCoord;
// int j = 0;
for (int i = 0; i < coord.length; i++) {
if (coord[i] != null) newCoord.add(coord[i]!);
// if (coord[i] != null) newCoord[j++] = coord[i]!;
}
return newCoord;
}