<p>I'm dealing with a large group of entities that store locations. They are displayed on a map. I'm trying to come up with an efficient way to group near located entities into one entity when viewed from a higher location. So, for example, if you are very high, when looking down, you will see one entity that represents a group of closely located entities in an area. Zooming in close enough would split that entity out into its contained entities.</p>

<p>Is there an efficient algorithm for doing this? I thought about just griding off the view based on height and dropping entities into grid boxes based on location then rendering the box point. My only concern is if all the entities are in the upper right of that box, the entity rendered to represent them might be centered in the middle instead of the location of the group of entities.</p>

<p>Any thoughts or ideas?</p>

You could use a regex against every key in the hashtable.  This is very dirty but it works:
```
```
static void Main(string[] args)
    {
        Hashtable myhashtable = new Hashtable();
        myhashtable.Add("Teststring", "Hello");
        myhashtable.Add("1TestString1", "World");
        myhashtable.Add("2TestString2", "Test");

        List<String> newht = new List<String>;

        //match all strings with a number at the front
        Regex rx = new Regex("^[1-9]");
        foreach (string key in myhashtable.Keys)
        {
            if (rx.IsMatch(key) == true)
            {
                newht.Add(key);
            }
        }

        //Loop through all the keys in the new collection and remove them from
        //them from the main hashtable.
        foreach (string key in newht)
        {
            myhashtable.Remove(key);
        }
    }
```
```
EDIT: And just for fun, here is the LINQ version (sorry I just had too).
```
```
Hashtable myhashtable = new Hashtable();
            myhashtable.Add("Teststring", "Hello");
            myhashtable.Add("1TestString1", "World");
            myhashtable.Add("2TestString2", "Test");

            Regex rx = new Regex("^[1-9]");
            var k = (from string key in myhashtable.Keys
                     where rx.IsMatch(key)
                     select key).ToList();

            k.ForEach(s => myhashtable.Remove(s));
```
```
EDIT: I have just added list of sting rather then a hashtable, I couldn't remember which .net version had generic lists in it ***slaps forehead