|
From: Per W. <pw...@ia...> - 2003-02-11 03:24:50
|
It's a bit hard to understand exactly what problem you want to solve. You might build a sorted priority queue with a <map>, where each entry is mapped from <prio,sequence> -> <entry>. A <map> is normally constructed from a RedBlack tree, i.e. an efficient form of balanced tree. Insert, Find, Remove etc will be performed in log time. /Per W On Mon, 10 Feb 2003, Samuel Keding wrote: > A bit of a strange question here. I want to make a queue that I > can search through for a flag and if the flag is set to one condition > perform operation A. If it is set to another condition do operation > B, etc, etc. I thought an effiecent way to do this would be to sort > the items before they go onto the queue, but to do this I would > have to have a function that can stick a queue element in between > other elements. With arrays this is terribly wastiful of time. Linked > lists are better but if I want to stick an element right in the > middle, I still have to follow the links all the way down the list. > I thought of dynamically allocating an array of pointers that point > to a datatype T (template) but I would still have to worry about > a bunch of assignment operations. The last option I can think of > is my original flag with an array, but I really wish I could come > up with a better way to sort the queue. Your help is appreciated. > > > > _____________________________________________________________ > Get 25MB, POP3, Spam Filtering with LYCOS MAIL PLUS for $19.95/year. > http://login.mail.lycos.com/brandPage.shtml?pageId=plus&ref=lmtplus > > > ------------------------------------------------------- > This SF.NET email is sponsored by: > SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See! > http://www.vasoftware.com > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |