Java 8 PriorityQueue - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 PriorityQueue class.

This code example shows how to use the following methods: offer, remove
    final E entry = super.get(key);
    if (entry != null) {
      if (accessExpirationPeriod > 0) {
        // update expiration time 
        final Entry existing = (Entry)entry;
        Preconditions.checkState(queue.remove(existing));
        setExpirationTime(existing, accessExpirationPeriod);
        queue.offer(existing);
      } 
    } 
    return entry;
  } 
 
  @Override 
  public E put(final E entry) {
    if (!(entry instanceof Entry)) {
      throw new HadoopIllegalArgumentException( 
          "!(entry instanceof Entry), entry.getClass()=" + entry.getClass());
    } 
 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isEmpty, remove, add, peek, size
  public String getModuleName() {
    return "com.google.gwt.emultest.EmulSuite"; 
  } 
 
  public void testBasic() { 
    PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
    assertEquals(0, pq.size());
    assertTrue(pq.isEmpty());
    assertNull(pq.peek());
    try { 
      pq.remove();
      fail("Expected exception"); 
    } catch (NoSuchElementException e) {
      // expected 
    } 
    pq.add(14);
    assertEquals(1, pq.size());
    assertFalse(pq.isEmpty());
    assertEquals(14, pq.peek().intValue());
    pq.add(5);

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: add, poll, size
    /** 
     * update the single sample multiplicities by adding the current single sample multiplicity to the priority queue, and 
     * reset the current single sample multiplicity to 0. 
     */ 
    public void flushSingleSampleMultiplicity() { 
        singleSampleMultiplicities.add(currentSingleSampleMultiplicity);
        if( singleSampleMultiplicities.size() == singleSampleCapacity + 1 ) {
            singleSampleMultiplicities.poll(); // remove the lowest multiplicity from the list
        } else if( singleSampleMultiplicities.size() > singleSampleCapacity + 1 ) {
            throw new IllegalStateException("Somehow the per sample multiplicity list has grown too big: " + singleSampleMultiplicities);
        } 
        currentSingleSampleMultiplicity = 0;
    } 
 
    @Override 
    public void incMultiplicity(final int incr) {
        super.incMultiplicity(incr);
        currentSingleSampleMultiplicity += incr;
    } 
 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: isEmpty, remove, add, peek, size
  public String getModuleName() {
    return "com.google.gwt.emultest.EmulSuite"; 
  } 
 
  public void testBasic() { 
    PriorityQueue<Integer> pq = new PriorityQueue<Integer>();
    assertEquals(0, pq.size());
    assertTrue(pq.isEmpty());
    assertNull(pq.peek());
    try { 
      pq.remove();
      fail("Expected exception"); 
    } catch (NoSuchElementException e) {
      // expected 
    } 
    pq.add(14);
    assertEquals(1, pq.size());
    assertFalse(pq.isEmpty());
    assertEquals(14, pq.peek().intValue());
    pq.add(5);

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: add, contains, size
        try { 
            if (contains(processId)) {
                return false; 
            } 
 
            int size = queue.size();
            queue.add(processId);
            if (size == 0) {
                notEmpty.signalAll();
            } 
            return true; 
        } finally { 
            lock.unlock();
        } 
    } 
 
    public boolean contains(Long processId) {
        return queue.contains(processId) || history.containsKey(processId);
    } 
 

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
See Code Examples for Java 8 PriorityQueue Methods: