public List <T> query(Rect bounds) { HashSet <T> result = new HashSet <T>(); var walker = new ScanlineWalker(bounds, gridSize); foreach (var index in walker) { HashSet <T> cellContents; if (grid.TryGetValue(index, out cellContents)) { foreach (var t in cellContents) { result.UnionWith(cellContents); } } } return(result.ToList()); }
public void Add(T t) { var bb = boxer(t); var walker = new ScanlineWalker(bb, gridSize); foreach (var index in walker) { HashSet <T> cellContents; if (grid.TryGetValue(index, out cellContents)) { cellContents.Add(t); } else { cellContents = new HashSet <T>(); cellContents.Add(t); grid.Add(index, cellContents); } } }