java.util.ArrayDeque.isEmpty()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.9k)|赞(0)|评价(0)|浏览(228)

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

ArrayDeque.isEmpty介绍

[英]Returns true if this deque contains no elements.
[中]如果此数据不包含任何元素,则返回true。

代码示例

代码示例来源:origin: iluwatar/java-design-patterns

/**
 * @return true if this iterator has a "next" element
 */
@Override
public boolean hasNext() {
 return !pathStack.isEmpty();
}

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

/**
 * Are there pending buffers in the queue.
 */
public final boolean isEmpty() {
  return bufAndListenerPairs.isEmpty();
}

代码示例来源:origin: eclipse-vertx/vert.x

/**
 * @return whether the buffer is empty
 */
public synchronized boolean isEmpty() {
 return pending.isEmpty();
}

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

/**
 * Are there pending buffers in the queue.
 */
public final boolean isEmpty() {
  return bufAndListenerPairs.isEmpty();
}

代码示例来源:origin: square/okhttp

synchronized boolean pong(ByteString payload) {
 // Don't send pongs after we've failed or sent the close frame.
 if (failed || (enqueuedClose && messageAndCloseQueue.isEmpty())) return false;
 pongQueue.add(payload);
 runWriter();
 return true;
}

代码示例来源:origin: square/okhttp

@Override public synchronized void onReadPing(ByteString payload) {
 // Don't respond to pings after we've failed or sent the close frame.
 if (failed || (enqueuedClose && messageAndCloseQueue.isEmpty())) return;
 pongQueue.add(payload);
 runWriter();
 receivedPingCount++;
}

代码示例来源:origin: iluwatar/java-design-patterns

/**
 * @return TreeNode next. The next element according to our in-order traversal of the given BST
 * @throws NoSuchElementException if this iterator does not have a next element
 */
@Override
public TreeNode<T> next() throws NoSuchElementException {
 if (pathStack.isEmpty()) {
  throw new NoSuchElementException();
 }
 TreeNode<T> next = pathStack.pop();
 pushPathToNextSmallest(next.getRight());
 return next;
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void onComplete() {
  final ArrayDeque<UnicastSubject<T>> ws = windows;
  while (!ws.isEmpty()) {
    ws.poll().onComplete();
  }
  downstream.onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void onComplete() {
    while (!buffers.isEmpty()) {
      downstream.onNext(buffers.poll());
    }
    downstream.onComplete();
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void onError(Throwable t) {
  final ArrayDeque<UnicastSubject<T>> ws = windows;
  while (!ws.isEmpty()) {
    ws.poll().onError(t);
  }
  downstream.onError(t);
}

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

synchronized boolean pong(ByteString payload) {
 // Don't send pongs after we've failed or sent the close frame.
 if (failed || (enqueuedClose && messageAndCloseQueue.isEmpty())) return false;
 pongQueue.add(payload);
 runWriter();
 return true;
}

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

@Override public synchronized void onReadPing(ByteString payload) {
 // Don't respond to pings after we've failed or sent the close frame.
 if (failed || (enqueuedClose && messageAndCloseQueue.isEmpty())) return;
 pongQueue.add(payload);
 runWriter();
 pingCount++;
}

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

@Override
public void onError(Throwable t) {
  final ArrayDeque<UnicastSubject<T>> ws = windows;
  while (!ws.isEmpty()) {
    ws.poll().onError(t);
  }
  actual.onError(t);
}

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

@Override
  public void onComplete() {
    while (!buffers.isEmpty()) {
      actual.onNext(buffers.poll());
    }
    actual.onComplete();
  }
}

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

@Override
public void onComplete() {
  final ArrayDeque<UnicastSubject<T>> ws = windows;
  while (!ws.isEmpty()) {
    ws.poll().onComplete();
  }
  actual.onComplete();
}

代码示例来源:origin: square/okhttp

@Override public void onReadClose(int code, String reason) {
 if (code == -1) throw new IllegalArgumentException();
 Streams toClose = null;
 synchronized (this) {
  if (receivedCloseCode != -1) throw new IllegalStateException("already closed");
  receivedCloseCode = code;
  receivedCloseReason = reason;
  if (enqueuedClose && messageAndCloseQueue.isEmpty()) {
   toClose = this.streams;
   this.streams = null;
   if (cancelFuture != null) cancelFuture.cancel(false);
   this.executor.shutdown();
  }
 }
 try {
  listener.onClosing(this, code, reason);
  if (toClose != null) {
   listener.onClosed(this, code, reason);
  }
 } finally {
  closeQuietly(toClose);
 }
}

代码示例来源:origin: ReactiveX/RxJava

/**
 * Returns a flattened list of Throwables from tree-like CompositeException chain.
 * @param t the starting throwable
 * @return the list of Throwables flattened in a depth-first manner
 */
public static List<Throwable> flatten(Throwable t) {
  List<Throwable> list = new ArrayList<Throwable>();
  ArrayDeque<Throwable> deque = new ArrayDeque<Throwable>();
  deque.offer(t);
  while (!deque.isEmpty()) {
    Throwable e = deque.removeFirst();
    if (e instanceof CompositeException) {
      CompositeException ce = (CompositeException) e;
      List<Throwable> exceptions = ce.getExceptions();
      for (int i = exceptions.size() - 1; i >= 0; i--) {
        deque.offerFirst(exceptions.get(i));
      }
    } else {
      list.add(e);
    }
  }
  return list;
}

代码示例来源:origin: square/okhttp

public void initReaderAndWriter(String name, Streams streams) throws IOException {
 synchronized (this) {
  this.streams = streams;
  this.writer = new WebSocketWriter(streams.client, streams.sink, random);
  this.executor = new ScheduledThreadPoolExecutor(1, Util.threadFactory(name, false));
  if (pingIntervalMillis != 0) {
   executor.scheduleAtFixedRate(
     new PingRunnable(), pingIntervalMillis, pingIntervalMillis, MILLISECONDS);
  }
  if (!messageAndCloseQueue.isEmpty()) {
   runWriter(); // Send messages that were enqueued before we were connected.
  }
 }
 reader = new WebSocketReader(streams.client, streams.source, this);
}

代码示例来源:origin: bumptech/glide

@Override
public Bitmap get(int width, int height, Bitmap.Config config) {
 return bitmaps.isEmpty() ? null : bitmaps.removeLast();
}

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

@Override
protected Record makeNext() {
  if (innerEntries.isEmpty())
    return allDone();
  AbstractLegacyRecordBatch entry = innerEntries.remove();
  // Convert offset to absolute offset if needed.
  if (wrapperMagic == RecordBatch.MAGIC_VALUE_V1) {
    long absoluteOffset = absoluteBaseOffset + entry.offset();
    entry = new BasicLegacyRecordBatch(absoluteOffset, entry.outerRecord());
  }
  if (entry.isCompressed())
    throw new InvalidRecordException("Inner messages must not be compressed");
  return entry;
}

相关文章