Priority queue in C#

I started writing articles about computer programming in 1989 when I saw an article in Computer Language Magazine about a topic I was working on at the time. I thought I had a better approach, so I coded up an example, wrote an article, and submitted it to Dr. Dobb’s Journal. I was ecstatic when they agreed to publish it and was surprised when they said that they’d actually pay for the article. I was just doing it for the glory.

Since then, most of my article ideas have come from stuff I run across at work. This latest article is no exception. In my crawler project there are several places where I need to assign priorities to things and then handle events or process items based on those priority values. Since the .NET runtime doesn’t include a priority queue, I implemented one myself. Thus was born my new article A Priority Queue Implementation in C#.

You can download the code for that article from www.mischel.com/pubs/priqueue.zip.

Charlie versus Little Foot

Little Foot is the neighbor’s cat. For the five years we’ve had Charlie, I’ve been warning the neighbors that if he catches the cat in the yard, I can’t be held responsible for the outcome. My neighbor said, “I know.”

Charlie cornered Little Foot yesterday–in a plastic trash can that had been knocked over by the wind. I won’t go into the whole sequence of events, but I will say that when Charlie’s head came out of the trash can he a very fuzzy growth attached to it.

The picture above doesn’t even come close to showing the damage that cat did to Charlie. The back of one ear is raw, his throat is scratched (apparently from the cat’s back claws), and he even has scratches inside his mouth. The last time I saw the cat, it was up in a tree. I suspect it wasn’t seriously injured.

I’m starting to think that Charlie should stay clear of the neighborhood wildlife. He killed a fawn years ago, and I found a dead bunny once, but mamma deer got the best of him, as did the skunk last year and the cat yesterday. I hate to think what’d happen if he found a raccoon.

Stupid dog.

Bug in CABINET.DLL?

I got a note the other day from somebody who was trying to use my .NET CAB file wrapper:

I have found an interesting case where I can make it fail every time in Vista using your C# wrapper. Just for the record, I do not believe this is a problem with your C# wrapper.

If my program is working from a directory of a name of 8 characters with the last byte a number, it will fail. eg: c:\ABCEDFG0

I didn’t have any words of wisdom, and asked him to tell me if he found any more information in this post on Microsoft’s forums. I haven’t had the opportunity to study the modifications the last poster made to my code, but it looks like he discovered a bug in my CabDotNet. There’s still the oddity of Vista’s cabinet.dll failing where the XP version works, but it’s possible that the XP version was just more tolerant of errors in the caller.

Whatever the case, I’ll have an updated version available as soon as I can. If you’re in a rush for it, you could implement the changes shown in the forum post.