My object apparently has no 'cargo' attribute

I'm a python/programming newb, and I am self-learning python. Unfortunately I'm really stuck! I'm in chapter 19 of "How to Think Like a Computer Scientist". The object here is to write an implementation of a Priority Queue ADT, using a linked li

Java Override CompareTo Method

I have Coordinates class and I want to make Coordinates object comparable. public class Coordinates implements Comparable<Coordinates> { private int row; private int column; The idea is to insert Coordinates objects into PriorityQueue and to get the

std :: priority_queue and make_heap API design

I was reading the documentation for priority_queue (basically a wrapper over make_heap), and it found out that you can customize it with a compare function. From the documentation(http://en.cppreference.com/w/cpp/container/priority_queue): A user-pro

Why can not I make a priority queue of struct type objects?

So I kinda know that I can't make a priority queue with type struct but I don't exactly understand the reason why? I mean if you can create template classes to make your own type, why would a struct be any different? This is what my code looks like i

Change the priority of an item in a PriorityQueue

I know that PriorityQueue automatically sorts the elements when add()ing one by using the objects' compareTo() method. Let's say I want to change the priority of an element in the queue at some point. How do I explicitly order the PriorityQueue to so

Simultaneous priority queue in redis?

I would like to implement a concurrent priority queue in Redis, with multiple processes on different machines adding items (with scores) and multiple other processes popping these items, lowest score first. A simple queue can be implemented with LPUS

Check if heapq contains value

I am using the heapq object to store objects of class which I implemented. import heapq heap = [] element1 = Element('A', 1) element2 = Element('B', 2) element3 = Element('C', 3) heapq.heappush(heap, element1) heapq.heappush(heap, element2) heapq.hea

Java: sorting the collection, returning modified indexes

In Java, I currently have my PriorityQueue set up to add the objects where they are needed in the list, ideally, I'd want to call a method on all of the moved items, for example: List = {0,10,20,30,40,50,60,70,80,90,100}. Add 55 List = {0,10,20,30,40

Prioritize certain workflow executions over others

I've been using the flow framework for amazon swf and I want to be able to run priority workflow executions and normal workflow executions. If there are priority tasks, then activities should pick up the priority tasks ahead of normal priority tasks.

The comparator in the priority queue has an error

Every line in my heap priority queue class have no errors except for the comparator in the HeapPriorityQueue constructor. I don't know how to fix it so there will be no error. I can't even check if the algorithm is working correctly because of the er

Test PriorityBlockingQueue in ThreadPoolExecutor

I realized my ThreadPoolExecutor with PriorityBlockingQueue like in this example: https://stackoverflow.com/a/12722648/2206775 and wrote a test: PriorityExecutor executorService = (PriorityExecutor) PriorityExecutor.newFixedThreadPool(16); executorSe

Complexity of PriorityQueue addAll ()

What is the complexity of the addAll method of PriorityQueue. Does it add one element at a time resulting in O(n log n) or does it use a build heap process that creates a heap out of unordered elements in O(n) time?Javadoc seems to imply that addAll

Does R have a priority queue like Java PriorityQueue?

I am looking for a general purpose priority queue in R. Does R has any general purpose priority queue implementation (package) like Java PriorityQueue class or Python heapq?I went ahead and implemented a basic queue as an R Reference Class. The detai

Binary heap deletion

I am just trying to learn binary heap and have a doubt regarding doing delete operation in binary heap. I have read that we can delete an element from binary heap and we need to reheapify it. But at the following link, it says unavailable: http://en.

Constant Size Priority Queue - Insert First or Delete First?

I am using a priority_queue to store the K closest points found so far in a K-nearest-neighbor search. When I find a point closer than the point at the top of the queue, I want to pop the top element and push the new one. if(point < pq.top()){ pq.pop

Custom comparator in stl

This has been driving me nuts for 3 hours. Anybody see a reason why this isn't working? struct sortByPropRev { bool operator()(const cust_type &a, const cust_type &b) const { return a.prop > b.prop; } }; ... priority_queue<cust_type, vector&

C ++, priority queue, items are not sorted

I have a problem with the priority queue: std::priority_queue <NodePrio, std::vector<NodePrio>, sortNodesByPrio> PQ; where struct NodePrio { Node *node; double priority; NodePrio() : node(NULL), priority(0) {} NodePrio(Node *node_, double prio

Priority Queue with a Search Function - Fastest Implementation

I am looking at implementing a priority queue with an added requirement, a find/search function which will tell whether an item is anywhere within the queue. So the functions will be: insert, del-min and find. I am unsure whether I should use a Heap

How to use iterators in Java?

I have implemented Priority Queue interface for making heap. Can you tell me how to implement an iterator on the top of that? point me to some apropriate tutorial,i am new to java and on a very short deadline here. Actually i need a method to find an

Problem with priority_queue - Memory write after heap

I am trying to use priority_queue, and program constantly fails with error message HEAP CORRUPTION DETECTED. here are the snippets: class CQueue { ... priority_queue<Message, deque<Message>, less<deque<Message>::value_type> > m_mes