Re: C# Deque found on the web--thanks to The Game Programming Wiki
- From: Peter Duniho <NpOeStPeAdM@xxxxxxxxxxxxxxxx>
- Date: Wed, 08 Aug 2007 11:28:10 -0700
Jon Skeet [C# MVP] wrote:
I'm curious what it is about your implementation that makes insertion of new items faster than if using a linked list?
The queue is ordered by priority, so it can use a binary search to find the correct insertion point. Binary search on a linked list isn't terribly fast :)
Well, not on an actual linked list. On a SortedList, it'd be fast, but then you have problems with insertions and removals and keeping the tree balanced, that sort of thing.
Admittedly it won't matter unless you've got thousands of items on the queue...
Nope. And I'd suggest that a more traditional approach, maintaining an ordered list of queues would work fine too (assuming that for a given priority, tasks are still FIFO). The ordered list could be a SortedList if one wants, but I think a regular list (linked or otherwise) maintained by insertion sort would be fine, given that the number of unique priorities is likely to be low.
You could have your queues and eat them too. :)
Pete
.
- References:
- C# Deque found on the web--thanks to The Game Programming Wiki
- From: raylopez99
- Re: C# Deque found on the web--thanks to The Game Programming Wiki
- From: Peter Duniho
- Re: C# Deque found on the web--thanks to The Game Programming Wiki
- From: Jon Skeet [C# MVP]
- Re: C# Deque found on the web--thanks to The Game Programming Wiki
- From: Peter Duniho
- Re: C# Deque found on the web--thanks to The Game Programming Wiki
- From: Jon Skeet [C# MVP]
- C# Deque found on the web--thanks to The Game Programming Wiki
- Prev by Date: Re: System.DirectoryServices Will not work
- Next by Date: Re: Getting ip addresses on the network
- Previous by thread: Re: C# Deque found on the web--thanks to The Game Programming Wiki
- Next by thread: Re: C# Deque found on the web--thanks to The Game Programming Wiki
- Index(es):
Relevant Pages
|