Best code examples for Java 8 PriorityQueue class (java.util.PriorityQueue)

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PriorityQueue class.
You can now enable Codota on your own code to easily search and navigate your Java codebase.

Java 8 PriorityQueue examples from Open Source projects
This code example shows how to use the following methods: offer, remove
199:	Preconditions.checkState(queue.remove(existing)); 
-
201:	queue.offer(existing); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: isEmpty, remove, add, peek, size
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
This code example shows how to use the following methods: add, poll, size
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
This code example shows how to use the following methods: isEmpty, remove, add, peek, size
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
This code example shows how to use the following methods: add, contains, size
67:	int size = queue.size(); 
68:	queue.add(processId); 
-
79:	return queue.contains(processId) || history.containsKey(processId); 
Full Snippet Info
7
CodeRank
This code example shows how to use the following methods: offer, peek, poll
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
This code example shows how to use the following methods: add, contains, size
77:	int size = tables.size(); 
-
79:	tables.add(processId);// 添加记录 
-
113:	return tables.contains(processId) || history.containsKey(processId); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods:
73:	queues.add(new PriorityQueue<Boolean>()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: isEmpty, add, peek, poll, size
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
This code example shows how to use the following methods: add, peek, remove, size
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
This code example shows how to use the following methods: isEmpty, remove, add, peek, size
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
This code example shows how to use the following methods:
34:	private final PriorityQueue<DelayedMessage> queue = new PriorityQueue<DelayedMessage>(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: add, poll, size
110:	if (sorted.size() > 0) { 
-
113:	sorted.add(currentTerm); 
-
115:	currentTerm = sorted.poll(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: contains, remove, add
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
This code example shows how to use the following methods: isEmpty, peek, size, remove
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
This code example shows how to use the following methods: size
68:	return this.queue.size(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: add, poll, size
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
This code example shows how to use the following methods: add, poll
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
This code example shows how to use the following methods:
39:	return marshallToCollection(new PriorityQueue<Object>(), o, ctx); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: isEmpty, add, peek
22:	return q.isEmpty() ? 0 : q.peek(); 
-
65:	perProject.add(newMaxI); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: add, size
17:	if (res.size() < limit_offset) { 
18:	res.add(mrow); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods:
48:	queues.add(new PriorityQueue<Boolean>()); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: offer, peek, poll, size
42:	if(heap.size()>=capacity){ 
43:	if(value > heap.peek()){ 
44:	heap.poll(); 
-
49:	heap.offer((float)value); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: add, peek, poll, size
53:	if (cvQueue.size() >= MAX_NUM) { 
54:	if (COMPARATOR.compare(cvQueue.peek(), cv) >= 0) { 
-
57:	cvQueue.poll(); 
-
60:	return cvQueue.add(cv); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: remove, add, size
316:	globalCandidates.add(row); 
-
318:	while (globalCandidates.size() > n) { 
319:	Block[] previous = globalCandidates.remove(); 
Full Snippet Info
6
CodeRank
This code example shows how to use the following methods: contains, offer
163:	if (!this.jobQueue1.contains(mapGeneratorJob)) { 
164:	this.jobQueue1.offer(mapGeneratorJob); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods:
232:	PriorityQueue<E> queue = new PriorityQueue<E>(); 
233:	Iterables.addAll(queue, elements); 
Full Snippet Info
5
CodeRank
This code example shows how to use the following methods: add, remove, size
78:	if (queue.remove(rtpPacket)) 
-
81:	return queue.add(rtpPacket) ; 
-
85:	if (queue.size() >= maxDepth) 
-
91:	return queue.add(rtpPacket) ; 
Full Snippet Info
5
CodeRank
See Code Examples for Java 8 PriorityQueue Methods: