Re: PriorityQueue Programming Software Development by Arthurr … static int Q=0; private static int LB=0; private PriorityQueue<node> queue; private node opt_node; public brunch_and_bound(int… { Comparator<node> compare = new nodecompartor(); PriorityQueue<node> queue = new PriorityQueue<node>(n,compare); } public node brunch_bound… Re: PriorityQueue Programming Software Development by jon.kiparsky … code beyond a few snippets - that you've declared a PriorityQueue called "queue", but when you get to your… has not been assigned to point to a correctly created PriorityQueue object on the heap. There are a few ways that… Re: PriorityQueue Programming Software Development by jon.kiparsky … called "queue" and pointed it to a new PriorityQueue of nodes. There was already a class field called queue…; was never touched. If the line reads [CODE] queue = new PriorityQueue<node>(n,compare);[/CODE] then it's not… Re: PriorityQueue Programming Software Development by Arthurr oh, you mean the PriorityQueue<node> statement repeats? That was the problem. But why? Re: PriorityQueue Programming Software Development by Arthurr oh i see the second time i typed the "priorityqueue<node>" but why it makes the queue null Calling toArray() on a PriorityQueue with Generic values Programming Software Development by pricey3000 … to implement a toArray() method in my PriorityQueue. The PriorityQueue returns an array of Objects, but I want…T1'. The following is the toArray() method from my PriorityQueue.java class. cpn = current priority node [CODE] public… [/CODE] The class definition is: [CODE]public class PriorityQueue<T1, T2 extends Comparable> {[/CODE] I'… Re: Calling toArray() on a PriorityQueue with Generic values Programming Software Development by pricey3000 … of elements (by getting the number of elements from my PriorityQueue by calling getLength) and then passing the array into my… own toArray method in my PriorityQueue. This allowed me to keep the required type, in my… PriorityQueue Programming Software Development by arthurr.ie I got a simple priority queue of <node> objects. [CODE] Priority Queue<node> queue = new Priority Queue<node>(n,compare);[/CODE] the node object has a few fields, one of them an int field called LB(lower bound) I've build a compare class so the queue would use my compare to sort itself. The problem is that when I'm trying… Re: PriorityQueue Programming Software Development by jon.kiparsky [QUOTE]I've tried adding a condition so that if one of the nodes X or Y is null return 1 but it didn't help [/QUOTE] If the null pointer were turning up in here: [CODE]# if(x.getLB()>=y.getLB()) return 1; if(x.getLB()<y.getLB()) return -1;[/CODE] then something like [CODE] if (x==null||y==null) return 1;[/CODE] would guard against that. … Re: PriorityQueue Programming Software Development by Arthurr It didn't help. the error i get is Exception in thread "main" java.lang.NullPointerException at brunch_and_bound.initiate(brunch_and_bound.java:71) at brunch_and_bound.brunch_bound(brunch_and_bound.java:26) at main.main(main.java:92) and it is at the line where I add to the queue [CODE] LB=Math.max(0, Q-input[i][3… Re: PriorityQueue Programming Software Development by jon.kiparsky If this [CODE]queue.add(N);[/CODE] is line 71, the there are two things that can be null there. To find out which it is, put in two test lines. [CODE]if (queue==null) S.o.println("queue is null"); if (N==null) S.o.println("N is null");[/CODE] Put those in just before the offending line. I have a suspicion about what's going… Re: PriorityQueue Programming Software Development by Arthurr queue is null.. Re: PriorityQueue Programming Software Development by jon.kiparsky Thought so. Okay, then - do you think you can work out why queue is null there? I can help you walk through it if you like, but you might find it worth doing yourself. Re: PriorityQueue Programming Software Development by Arthurr if you can walk me through I'd be glad I'm not a seasoned programmer, and this is only a school assignment. Re: PriorityQueue Programming Software Development by jon.kiparsky Oh, okay, that was simple. Look at your constructor. What happens on the second line? Re: PriorityQueue Programming Software Development by Arthurr thanks a lot! This "little typo" kept me behind for two days! Re: PriorityQueue Programming Software Development by jon.kiparsky Glad it helped. Go ahead and mark the thread as solved, then... Re: PriorityQueue Programming Software Development by Arthurr I can't see the "solved" button. or i just don't know where to look Re: PriorityQueue Programming Software Development by jon.kiparsky You should see the link directly below the words "Has this thread been answered?" at the bottom of the thread... Re: Calling toArray() on a PriorityQueue with Generic values Programming Software Development by moutanna there is some missing class in you poste so I could not compile you code but please try this modification: [CODE] public Object[] toArray() { ArrayList<T1> al = new ArrayList<T1>(length); PriorityNode<T1,T2> cpn = head; for (int i = 0; i < length; i++) { al.add(cpn.getData()); cpn = cpn.getNext(); } return (… Re: Doubt in Priority Queue Programming Software Development by JamesCherrill PriorityQueue uses a private array to hold the queue. It automatically … Re: Priority Queue is not sorting as per Natural Order Programming Software Development by JamesCherrill PriorityQueue inherits its toString() from java.util.AbstractCollection, which doesn't know about sort orders. (println uses toString() on all its arguments). If you poll() the elements as intended, you get them in the correct order, eg Integer i; while ((i = pq.poll())!= null) System.out.print(i + " "); Have trouble with a dijkstra program Programming Software Development by ericcool … edge { return ptr[v_1][v_2]; } //PriorityQueue.h class PriorityQueue { public: PriorityQueue(int nodes, int source); // constructor void …] = temp_2; index = min_child_index; } else { return; } } } int PriorityQueue::ExtractMin() // returns the node with the minimum distance { int min… huffman decode Programming Software Development by Delters1 … PQPriorityType; struct PriorityQueue { int* ptr; PriorityQueue() { ptr = NULL; } }; void insert(PriorityQueue& q,…=c; c=c->next; } } bool isEmpty(PriorityQueue q) { return !q.ptr; } ////////////////////////////////////// //tree.… Need help with C++ priority queue programming project Programming Software Development by Zack_9 … void insertCell(PriorityQueue& L…PriorityQueue { PriorityQueue* next; PriorityQueue() { next = NULL; } }; //Prototypes bool isEmpty(const PriorityQueue& q); void insert(PriorityQueue Re: Need help with C++ priority queue programming project Programming Software Development by Schol-R-LEA PriorityQueue { PQCell* node; PriorityQueue* next; PriorityQueue() { next = NULL; } }; //Prototypes bool isEmpty(const PriorityQueue& q); void insert(PriorityQueue… void insertCell(PriorityQueue& L… Queues Java Programming Software Development by ITOzann …// Private data fields: // define one priority queue private PriorityQueue <Cashier> busyCashierQ; // define two FIFO queues … compare() in Comparator to compare Cashier objects busyCashierQ = new PriorityQueue<Cashier>( numCashiers, new CompareCashier()); // initialize customerQlimit… Priority Queue help Programming Software Development by BuhRock …} return leastFullRegister; } } [/CODE] Register: [CODE]import java.util.PriorityQueue; public class Register implements Comparable<Register> { private boolean…(){ open = false; waitTime = 0; this.line = new PriorityQueue<Customer>(); } public double getTotalEnqueue(){ double totalTime = 0… Priority Queue Implementation Programming Software Development by becdudek …override abstract method iterator() in DAT.PriorityQueue public class PriorityQueueLinked implements PriorityQueue { ^ 1 error [/CODE]….*; /** * A Linked Priority Queue. **/ public class PriorityQueueLinked implements PriorityQueue { private Link front; // Constructor public PriorityQueueLinked() { front = null… please help me with my homework- priority queue Programming Software Development by katzumi_r … array as its implementation. The class specification file, [I]priorityQueue.h,[/I] is given and should be used as your… guideline. You must add the implementation file, [I]priorityQueue.cpp,[/I] and create the driver file [I]p06.cpp… create the driver file i have attached the files priorityQueue.h - the header file given p06.doc - the …