/* NumberOfCleanedSpots calculates the number of unique * points of the intervals that are present on a specified y-slice of the plane */ private long NumberOfCleanedSpots(int x, List <CleanedInterval> sortedListOfIntervals) { HashSet <int> coordsOnAxis = new HashSet <int>(); for (int k = 0; k < sortedListOfIntervals.Count; k++) { CleanedInterval interval = sortedListOfIntervals[k]; if (interval.xMax < x) { continue; } bool isxInInterval = interval.xMin <= x && interval.xMax >= x; if (isxInInterval) { for (int j = interval.yMin; j <= interval.yMax; j++) { coordsOnAxis.Add(j); } coordsOnAxis.Add(interval.yMax); } } return(coordsOnAxis.Count); }
public void AllocateMemory(Coordinates start, Coordinates end) { CleanedInterval interval = new CleanedInterval(start.x, end.x, start.y, end.y); memory.Add(interval); }