Code examples for PriorityQueue

Codota analyzed 7,668,838 open source code samples to find the most common, credible and clear examples.
You can now enable Codota on your own code to easily search and navigate your Java codebase.
199:	Preconditions.checkState(queue.remove(existing)); 
-
201:	queue.offer(existing); 
Full Snippet Info
7
CodeRank
67:	int size = queue.size(); 
68:	queue.add(processId); 
-
79:	return queue.contains(processId) || history.containsKey(processId); 
Full Snippet Info
7
CodeRank
36:	PriorityQueue<Integer> pq = new PriorityQueue<Integer>(); 
37:	assertEquals(0, pq.size()); 
38:	assertTrue(pq.isEmpty()); 
39:	assertNull(pq.peek()); 
-
41:	pq.remove(); 
-
46:	pq.add(14); 
47:	assertEquals(1, pq.size()); 
48:	assertFalse(pq.isEmpty()); 
49:	assertEquals(14, pq.peek().intValue()); 
50:	pq.add(5); 
51:	assertEquals(2, pq.size()); 
52:	assertFalse(pq.isEmpty()); 
53:	assertEquals(5, pq.peek().intValue()); 
54:	pq.add(7); 
55:	assertEquals(3, pq.size()); 
56:	assertFalse(pq.isEmpty()); 
57:	assertEquals(5, pq.peek().intValue()); 
58:	pq.add(3); 
59:	assertEquals(4, pq.size()); 
60:	assertFalse(pq.isEmpty()); 
61:	assertEquals(3, pq.peek().intValue()); 
62:	assertEquals(3, pq.remove().intValue()); 
63:	assertEquals(5, pq.remove().intValue()); 
64:	assertEquals(7, pq.remove().intValue()); 
65:	assertEquals(14, pq.remove().intValue()); 
66:	assertTrue(pq.isEmpty()); 
Full Snippet Info
7
CodeRank
99:	singleSampleMultiplicities.add(currentSingleSampleMultiplicity); 
100:	if( singleSampleMultiplicities.size() == singleSampleCapacity + 1 ) { 
101:	singleSampleMultiplicities.poll(); // remove the lowest multiplicity from the list 
102:	} else if( singleSampleMultiplicities.size() > singleSampleCapacity + 1 ) { 
Full Snippet Info
6
CodeRank
36:	PriorityQueue<Integer> pq = new PriorityQueue<Integer>(); 
37:	assertEquals(0, pq.size()); 
38:	assertTrue(pq.isEmpty()); 
39:	assertNull(pq.peek()); 
-
41:	pq.remove(); 
-
46:	pq.add(14); 
47:	assertEquals(1, pq.size()); 
48:	assertFalse(pq.isEmpty()); 
49:	assertEquals(14, pq.peek().intValue()); 
50:	pq.add(5); 
51:	assertEquals(2, pq.size()); 
52:	assertFalse(pq.isEmpty()); 
53:	assertEquals(5, pq.peek().intValue()); 
54:	pq.add(7); 
55:	assertEquals(3, pq.size()); 
56:	assertFalse(pq.isEmpty()); 
57:	assertEquals(5, pq.peek().intValue()); 
58:	pq.add(3); 
59:	assertEquals(4, pq.size()); 
60:	assertFalse(pq.isEmpty()); 
61:	assertEquals(3, pq.peek().intValue()); 
62:	assertEquals(3, pq.remove().intValue()); 
63:	assertEquals(5, pq.remove().intValue()); 
64:	assertEquals(7, pq.remove().intValue()); 
65:	assertEquals(14, pq.remove().intValue()); 
66:	assertTrue(pq.isEmpty()); 
Full Snippet Info
7
CodeRank
14:	PriorityQueue<String> q = new PriorityQueue<String>(); // Create OBJECT "q". 
-
17:	q.offer("first"); // The first thing we pass in will be the highest priority. 
18:	q.offer("second"); 
19:	q.offer("third"); 
-
27:	System.out.printf("%s ", q.peek()); //we use the "peek()" METHOD to PEEK at the QUEUE "q". Returns "first". 
-
34:	q.poll(); //we don't have to give it an ARGUMENT, because it already knows to find the ELEMENT with the highest priority. 
Full Snippet Info
6
CodeRank
77:	int size = tables.size(); 
-
79:	tables.add(processId);// 添加记录 
-
113:	return tables.contains(processId) || history.containsKey(processId); 
Full Snippet Info
6
CodeRank
73:	queues.add(new PriorityQueue<Boolean>()); 
Full Snippet Info
6
CodeRank
32:	if((maxHeap.size() + minHeap.size()) % 2 == 0) 
-
34:	if(!maxHeap.isEmpty() && n < maxHeap.peek()) 
-
36:	maxHeap.add(n); 
37:	n = maxHeap.poll(); 
-
40:	return maxHeap.peek(); 
-
49:	maxHeap.add(n); 
50:	return ( maxHeap.peek() + minHeap.peek() )/2 ; 
Full Snippet Info
6
CodeRank
85:	if (heap.size() < k) { 
-
87:	heap.add(new SimpleImmutableEntry<T,Double>(key, value)); 
-
90:	heap.add(new SimpleImmutableEntry<T,Double>(key, value)); 
-
94:	} else if ((max && (heap.peek().getValue() < value)) || 
95:	((!max) && (heap.peek().getValue() > value))) { 
-
97:	pair = heap.peek(); 
-
99:	heap.remove(pair); 
100:	heap.add(new SimpleImmutableEntry<T,Double>(key, value)); 
-
105:	heap.remove(pair); 
106:	heap.add(new SimpleImmutableEntry<T,Double>(key, value)); 
Full Snippet Info
6
CodeRank
36:	PriorityQueue<Integer> pq = new PriorityQueue<Integer>(); 
37:	assertEquals(0, pq.size()); 
38:	assertTrue(pq.isEmpty()); 
39:	assertNull(pq.peek()); 
-
41:	pq.remove(); 
-
46:	pq.add(14); 
47:	assertEquals(1, pq.size()); 
48:	assertFalse(pq.isEmpty()); 
49:	assertEquals(14, pq.peek().intValue()); 
50:	pq.add(5); 
51:	assertEquals(2, pq.size()); 
52:	assertFalse(pq.isEmpty()); 
53:	assertEquals(5, pq.peek().intValue()); 
54:	pq.add(7); 
55:	assertEquals(3, pq.size()); 
56:	assertFalse(pq.isEmpty()); 
57:	assertEquals(5, pq.peek().intValue()); 
58:	pq.add(3); 
59:	assertEquals(4, pq.size()); 
60:	assertFalse(pq.isEmpty()); 
61:	assertEquals(3, pq.peek().intValue()); 
62:	assertEquals(3, pq.remove().intValue()); 
63:	assertEquals(5, pq.remove().intValue()); 
64:	assertEquals(7, pq.remove().intValue()); 
65:	assertEquals(14, pq.remove().intValue()); 
66:	assertTrue(pq.isEmpty()); 
Full Snippet Info
6
CodeRank
316:	globalCandidates.add(row); 
-
318:	while (globalCandidates.size() > n) { 
319:	Block[] previous = globalCandidates.remove(); 
Full Snippet Info
6
CodeRank
34:	private final PriorityQueue<DelayedMessage> queue = new PriorityQueue<DelayedMessage>(); 
Full Snippet Info
6
CodeRank
110:	if (sorted.size() > 0) { 
-
113:	sorted.add(currentTerm); 
-
115:	currentTerm = sorted.poll(); 
Full Snippet Info
6
CodeRank
191:	log.trace("SPITTING IT BACK TO THE USER! NUMBER : " + termsPQ.size()); 
192:	if (!termsPQ.isEmpty() && (next = termsPQ.peek()) != null) { 
-
196:	termsPQ.remove(); 
Full Snippet Info
6
CodeRank
146:	Queue<RtpPacket> q = new PriorityQueue<RtpPacket>(); 
147:	q.add(a); 
148:	q.add(b); 
-
150:	assertTrue(q.contains(a)); 
151:	assertTrue(q.contains(b)); 
152:	assertTrue(q.contains(c)); 
153:	assertFalse(q.contains(d)); 
154:	assertTrue(q.remove(c)); 
155:	assertFalse(q.remove(a)); 
Full Snippet Info
6
CodeRank
68:	return this.queue.size(); 
Full Snippet Info
6
CodeRank
108:	singleSampleMultiplicities.add(currentSingleSampleMultiplicity); 
109:	if( singleSampleMultiplicities.size() == singleSampleCapacity + 1 ) { 
110:	singleSampleMultiplicities.poll(); // remove the lowest multiplicity from the list 
111:	} else if( singleSampleMultiplicities.size() > singleSampleCapacity + 1 ) { 
Full Snippet Info
6
CodeRank
22:	return q.isEmpty() ? 0 : q.peek(); 
-
65:	perProject.add(newMaxI); 
Full Snippet Info
6
CodeRank
177:	Entry current = queue.poll(); 
-
201:	queue.add(merged); 
-
211:	queue.add(new Entry(left.getId(), left.getValue(), left.getWeight(), left.getLeft(), merged)); 
-
275:	PriorityQueue<Entry> queue = new PriorityQueue<>(nextIndex); 
-
278:	queue.add(right); 
-
281:	queue.add(current); 
Full Snippet Info
6
CodeRank