java.util.Deque.peekLast()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(231)

本文整理了Java中java.util.Deque.peekLast()方法的一些代码示例,展示了Deque.peekLast()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Deque.peekLast()方法的具体详情如下:
包路径:java.util.Deque
类名称:Deque
方法名:peekLast

Deque.peekLast介绍

[英]Retrieves, but does not remove, the last element of this deque, or returns null if this deque is empty.
[中]检索但不删除此deque的最后一个元素,如果此deque为空,则返回null。

代码示例

代码示例来源:origin: google/j2objc

@Override
public E peekLast() {
 synchronized (mutex) {
  return delegate().peekLast();
 }
}

代码示例来源:origin: google/guava

@Override
public E peekLast() {
 synchronized (mutex) {
  return delegate().peekLast();
 }
}

代码示例来源:origin: google/guava

@Override
public E peekLast() {
 return delegate().peekLast();
}

代码示例来源:origin: MovingBlocks/Terasology

public Chunk getLatestChunk() {
  final WeakReference<Chunk> chunk = chunks.peekLast();
  if (chunk != null) {
    return chunk.get();
  }
  return null;
}

代码示例来源:origin: twosigma/beakerx

/**
 * Is the last character the one expected?
 */
boolean isLastChar(char expectedChar) {
 return prevTwoChars.size() >= 1 && prevTwoChars.peekLast().equals(expectedChar);
}

代码示例来源:origin: prestodb/presto

@Override
public E peekLast() {
 synchronized (mutex) {
  return delegate().peekLast();
 }
}

代码示例来源:origin: btraceio/btrace

public static <V> V peekLast(Deque<V> queue) {
  if (queue instanceof BTraceDeque || queue.getClass().getClassLoader() == null) {
    return queue.peekLast();
  } else {
    throw new IllegalArgumentException();
  }
}

代码示例来源:origin: prestodb/presto

@Override
public E peekLast() {
 return delegate().peekLast();
}

代码示例来源:origin: jersey/jersey

private List<ErrorMessage> _getErrorMessages(final boolean afterMark) {
  if (afterMark) {
    final Integer _pos = mark.peekLast();
    final int markedPos = (_pos == null) ? -1 : _pos;
    if (markedPos >= 0 && markedPos < issues.size()) {
      return Collections.unmodifiableList(new ArrayList<ErrorMessage>(issues.subList(markedPos, issues.size())));
    } // else return all errors
  }
  return Collections.unmodifiableList(new ArrayList<ErrorMessage>(issues));
}

代码示例来源:origin: jersey/jersey

private List<ErrorMessage> _getErrorMessages(final boolean afterMark) {
  if (afterMark) {
    final Integer _pos = mark.peekLast();
    final int markedPos = (_pos == null) ? -1 : _pos;
    if (markedPos >= 0 && markedPos < issues.size()) {
      return Collections.unmodifiableList(new ArrayList<ErrorMessage>(issues.subList(markedPos, issues.size())));
    } // else return all errors
  }
  return Collections.unmodifiableList(new ArrayList<ErrorMessage>(issues));
}

代码示例来源:origin: google/j2objc

@Override
public E peekLast() {
 return delegate().peekLast();
}

代码示例来源:origin: google/guava

@Override
public E peekLast() {
 assertTrue(Thread.holdsLock(mutex));
 return delegate.peekLast();
}

代码示例来源:origin: btraceio/btrace

public void addInstrumentor(BTraceProbe bp, ClassLoader cl) {
  if (cr != null && bp != null) {
    synchronized(instrumentors) {
      Instrumentor top = instrumentors.peekLast();
      ClassVisitor parent = top != null ? top : this;
      Instrumentor i = Instrumentor.create(cr, bp, parent, cl);
      if (i != null) {
        instrumentors.add(i);
      }
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public E peekLast() {
 synchronized (mutex) {
  return delegate().peekLast();
 }
}

代码示例来源:origin: apache/incubator-druid

/**
 * Submit a fetch task if remainingBytes is smaller than prefetchTriggerBytes.
 */
private void fetchIfNeeded(long remainingBytes)
{
 if ((fetchFutures.isEmpty() || fetchFutures.peekLast().isDone())
   && remainingBytes <= prefetchConfig.getPrefetchTriggerBytes()) {
  Future<Void> fetchFuture = fetchExecutor.submit(() -> {
   fetch();
   return null;
  });
  fetchFutures.add(fetchFuture);
 }
}

代码示例来源:origin: apache/storm

private void initPartitions() {
  partitionIds = partitionIdsState.get(PARTITION_IDS_KEY, new LinkedList<>());
  if (partitionIds.isEmpty()) {
    partitionIds.add(0L);
    partitionIdsState.put(PARTITION_IDS_KEY, partitionIds);
  }
  latestPartitionId = partitionIds.peekLast();
  latestPartition = cache.pinAndGet(latestPartitionId);
}

代码示例来源:origin: btraceio/btrace

public byte[] instrument() {
  boolean hit = false;
  synchronized(instrumentors) {
    if (instrumentors.isEmpty()) return null;
    ClassVisitor top = instrumentors.peekLast();
    InstrumentUtils.accept(cr, top != null ? top : this);
    for(Instrumentor i : instrumentors) {
      hit |= i.hasMatch();
    }
  }
  return hit ? this.toByteArray() : null;
}

代码示例来源:origin: ben-manes/caffeine

private void checkDeque(Deque<? extends E> deque, DescriptionBuilder builder) {
 builder.expectThat("empty deque", deque.peekFirst(), is(nullValue()));
 builder.expectThat("empty deque", deque.peekLast(), is(nullValue()));
 builder.expectThat("empty deque", deque.descendingIterator().hasNext(), is(false));
}

代码示例来源:origin: apache/kafka

/**
 *  Try to append to a ProducerBatch.
 *
 *  If it is full, we return null and a new batch is created. We also close the batch for record appends to free up
 *  resources like compression buffers. The batch will be fully closed (ie. the record batch headers will be written
 *  and memory records built) in one of the following cases (whichever comes first): right before send,
 *  if it is expired, or when the producer is closed.
 */
private RecordAppendResult tryAppend(long timestamp, byte[] key, byte[] value, Header[] headers,
                   Callback callback, Deque<ProducerBatch> deque) {
  ProducerBatch last = deque.peekLast();
  if (last != null) {
    FutureRecordMetadata future = last.tryAppend(timestamp, key, value, headers, callback, time.milliseconds());
    if (future == null)
      last.closeForRecordAppends();
    else
      return new RecordAppendResult(future, deque.size() > 1 || last.isFull(), false);
  }
  return null;
}

代码示例来源:origin: google/guava

create().getLast();
create().peekFirst();
create().peekLast();
create().removeFirstOccurrence("e");
create().removeLastOccurrence("e");

相关文章