I was working on a sensor driver sample last week, the one I wrote about below. One of the requirements of the sample is that the driver must keep track of the list of requested report intervals. The idea is that the driver will fire events at the shortest requested interval, but if a client app stops listening to events, then that app's interval request should be removed from the list.

Now, I'm in the habit of writing my own classes for lists, queues, and so forth...I don't know why. I guess I just like to keep things as simple as possible, so I write very simple classes to do this sort of work in samples. But in this case, I started hunting around for a standard class, and I first looked at the standard library. A lot of my coworkers have a sort of bias against the STL, but I never have...though I get that it can be overkill.

Anyway, while hunting around for the right fit, it dawned on me that the sample is already using ATL. Surely ATL must have something to fit my needs, right? And there it was! CSimpleMap: http://msdn.microsoft.com/en-us/library/d1xc3983(VS.80).aspx.

Everything I needed, not much I didn't want, and ATL was already in the mix.

Like the name says, the class is simple. You provide a key and a value when you call Add:

   const TKey& key,
   const TVal& val 

The class behaves like a simple hash table. You can find a key, find a value, work with indexes like an array, assign a new value to an existing key, remove a key...all the basic operations you'd usually want when maintaining a simple collection.

Very nice.