public uint[] QueryRegion(Rectangle bounds)
{
HashSet<uint> matches = new HashSet<uint>();
// Find the maximal index for the bounding region in the vertical
// axis list
Bound top = new Bound(null, bounds.Top, BoundType.Min);
int minVerticalIndex = verticalAxis.BinarySearch(top);
if (minVerticalIndex < 0) minVerticalIndex = ~minVerticalIndex;
// Find the minimal index for the bounding region in the vertical
// axis list
Bound bottom = new Bound(null, bounds.Bottom, BoundType.Max);
int maxVerticalIndex = verticalAxis.BinarySearch(bottom);
if (maxVerticalIndex < 0) maxVerticalIndex = ~maxVerticalIndex;
// Collect all game object ids between the minimal and maximal
// indices
for (int i = minVerticalIndex; i < maxVerticalIndex; i++)
{
matches.Add(verticalAxis[i].Box.GameObjectID);
}
return matches.ToArray();
}