Namely the ability to remove things prematurely that I did not want in the queue.
So tonight I was bored and wrote up a VERY simple queue system. It's NOT perfect but it seems to work in my initial tests.
It's storing objects so you can use it to store ANY VALUE YOU LIKE! Just be sure you are checking the type you are holding before you try to process it..
EXAMPLES OF HOW TO USE!
Simply add the reference to your project and then add it to your 'using' statements wherever you plan to setup the queue.
Personally I have it in my map structure to hold ground items (that way I can remove them from the server based on timeout in order they are dropped OR remove them when looted regardless of where they are in the queue)
Code:
using Queuing;
Code:
Queueing.Queue Items = new Queueing.Queue();
Count: returns number of objects in the queue currently
Peek(): returns but does NOT remove the first object in the queue (next to be processed). Use for checks
Dequeue(): returns and removes the first object in queue (next to be processed)
Queue(object): adds the specified object to the END of the queue (LAST to be processed)
Remove(object): Removes the specified object from the queue regardless of its position.
Now! be sure to interpret the data that you are receiving back from the queue. You can do this with simple if checks.
Eg:
if(!(ItemsQueue.Peek is GroundItem)
return;
Be sure to convert your returned data into this type also!
eg:
GroundItem I = (GroundItem) ItemsQueue.Dequeue();
It's not obfuscated so feel free to decompose and offer criticism. It's simply a dictionary which adds/returns based on current object count. Nothing fancy at all.
I'm just starting to write some dll's (had never done it before) so maybe next time I'll do something more useful.
<edit>
Updated file: I was dumb and did a couple things wrong for the Remove(object) method. It works now. Please provide input and anything else you'd like to see done with it or other methods you'd like added.
Anyone have suggestions for dynamic handling of types? objects were the best way I could envision holding data but I wasn't sure if there is something better in C# to use to define what should be held or w/e.