Priority queue in .Net
I am looking for a .Net (preferably C#) implementation of a priority queue or heap. Unless I am looking in the wrong place, there isn't one in the framework. Is anyone aware of a good one, or should I roll my own? ...
I am looking for a .Net (preferably C#) implementation of a priority queue or heap. Unless I am looking in the wrong place, there isn't one in the framework. Is anyone aware of a good one, or should I roll my own? ...
UPDATE: Here's my implementation of Hashed Timing Wheels. Please let me know if you have an idea to improve the performance and concurrency. (20-Jan-2009) // Sample usage: public static void main(String[] args) throws Exception { Timer timer = new HashedWheelTimer(); for (int i = 0; i < 100000; i ++) { timer.newTimeout(...
I am implementing a small queue to handle which process gets to run first. I am using a table in a database to do this. Here is the structure of the table (I'm mocking it up in SQLite): "id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL , "identifier" VARCHAR NOT NULL , "priority_number" INTEGER DEFAULT 15, ...
Using the STL's priority_queue I get the error "invalid heap" as soon as I try to use pop(). I can push my values into the queue, the top() of the queue is what I would expect and accessible. pop(), when it goes to re-heap, seems to have a problem. I am storing pointers to a templated class in the queue. I have the comparision overloade...
I have a queuing mechanism in C on Unix. It accepts XML transactions. Some transactions contain records to be stored. Other transactions request those transactions. The transactions get stored in a file, which is a home-grown queue. First in, first out, very simple. Header area at start of file, keeps track of next position to read from,...
I need a data structure that always holds the n largest items inserted so far (in no particular order). So, if n is 3, we could have the following session where I insert a few numbers and the content of the container changes: [] // now insert 1 [1] // now insert 0 [1,0] // now insert 4 [1,0,4] // now insert 3 [1,4,3] // now insert 0 ...
Java's priority queue is a data structure with O(log n) complexity for put (insertion) and O(log n) for poll (retrieval and removal of the min element). C++ STL's multimap has the same functionality but O(1) complexity for retrieval and removal of the min element (begin and erase). Is there an equivalent in Java ? ...
I'm gonna implement a scheduler using thread pool & priority queue in Java and I want to ask whether anybody knows any existing implementations or not, so I don't have spend time on it :-)... Basically, the ScheduledThreadPoolExecutor in java.util.concurrent package provides almost functions I need except the "priority queue". As I roug...
I have a priority_queue of some object: typedef priority_queue<Object> Queue; Queue queue; From time to time, the priority of one of the objects may change - I need to be able to update the priority of that object in the queue in an efficient way. Currently I am using this method which works but seems inefficient: Queue newQueue; whi...
I'd like to wrap java's PriorityQueue class in clojure for use in another part of my program. What I'm trying to figure out is if there is any way to do this in a lispy manner and make the priority queue immutable. Are there any good ways to do this, or am I just going to be better off using the PriorityQueue as a mutable data structur...
How do I get a PriorityQueue to sort on what I want it to sort on? Added: And is there a difference between the offer and add methods? ...
note, I am not asking for answers. I simply am curious regarding why things work I need to implement a priority queue for a printer simulator for a class assignment. After looking at examples on the internet, I noticed that operator< was being overloaded in order to arrange the priority queue correctly. code in question: java2s prior...
Does Java have an easy way to reevaluate a heap once the priority of an object in a PriorityQueue has changed? I can't find any sign of it in Javadoc, but there has to be a way to do it somehow, right? I'm currently removing the object then re-adding it but that's obviously slower than running update on the heap. ...
For my CS class I need to implement Prim's algorithm in Java and I am having problems with the priority queue step. I have experience with priority queues and understand they work in general but I am having trouble with a particular step. Prim(G,w,r) For each u in V[G] do key[u] ← ∞ π[u] ← NIL key[r] ← 0 Q ← V[G] ...
I have a class that I would like to use in a scala.collection.mutable.PriorityQueue, but I don't want to make it Ordered[A] just for this one purpose. I don't consider the ordering I want to use with respect to the PriorityQueue as the natural ordering of the class. class MyObject (sequence: Int, values: List[String]) ... So, in my ...
I have a priority queue of events, but sometimes the event priorities change, so I'd like to maintain iterators from the event requesters into the heap. If the priority changes, I'd like the heap to be adjusted in log(n) time. I will always have exactly one iterator pointing to each element in the heap. ...
I'm using a priority queue that initially bases the priority of its elements on a heuristic. As elements are dequeued the heuristic is updated and elements currently in the queue may have their keys increased. I know there are heaps (Fibonacci heaps specifically) that have amortized O(1) decrease key operations, but are there any heap ...
Hello, Priority receive in Erlang can easily be implemented as follows: prio() -> receive {priority, X} -> X after 0 -> receive X -> X end end. I am reading a paper called Priority Messaging made Easy in which they describe the following problem: The main problem with the [code] example [above], is ...
My priority queue declared as: std::priority_queue<*MyClass> queue; class MyClass { bool operator<( const MyClass* m ) const; } is not sorting the items in the queue. What is wrong? I would not like to implement a different (Compare) class. Answer summary: The problem is, the pointer addresses are sorted. The only way to avoid...
What is the preferred way, if any, to handle channel input in a prioritized fashion? Is there anything equivalent to Scala's "reactWithin(0) { ... case TIMEOUT }" construct? ...