private static int convertSpanToSparseGrid(int curIx,int span,TreeSet<Integer> indexes){
  int lastIx=curIx + span;
  int retSpan=1;
  for (  Integer ix : indexes) {
    if (ix <= curIx) {
      continue;
    }
    if (ix >= lastIx) {
      break;
    }
    retSpan++;
  }
  return retSpan;
}

private static int convertSpanToSparseGrid ( int curIx , int span , TreeSet < Integer > indexes ) { int lastIx = curIx + span ; int retSpan = 1 ; for ( Integer ix : indexes ) { if ( ix <= curIx ) { continue ; } if ( ix >= lastIx ) { break ; } retSpan ++ ; } return retSpan ; }
spanning is specified in the uncompressed grid number . they can for instance be more than 60000 for the outer edge dock grid cells . when the grid is compressed and indexed after only the cells that area occupied the span is erratic . this method use the row / col indexes and corrects the span to be correct for the compressed grid .
