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

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

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

ArrayDeque.size介绍

[英]Returns the number of elements in this deque.
[中]返回此数据块中的元素数。

代码示例

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

/**
 * Get the number of elements in this queue added via one of the {@link #add(ByteBuf)} methods.
 * @return the number of elements in this queue.
 */
protected final int size() {
  return bufAndListenerPairs.size();
}

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

/**
 * @return whether the buffer is writable
 */
public synchronized boolean isWritable() {
 return pending.size() <= highWaterMark;
}

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

/**
  * @return the actual number of elements in the buffer
  */
 public synchronized int size() {
  return pending.size();
 }
}

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

/**
 * Get the number of elements in this queue added via one of the {@link #add(ByteBuf)} methods.
 * @return the number of elements in this queue.
 */
protected final int size() {
  return bufAndListenerPairs.size();
}

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

/**
   * Gets the number of Runnables currently queued.
   */
  public int numQueuedRunnables() {
    synchronized (queuedRunnables) {
      return queuedRunnables.size();
    }
  }
}

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

@Override
public int size() {
  return queue.size();
}

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

@VisibleForTesting
public int getPoolSize()
{
 return objects.size();
}

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

/**
 * Gets the number of elements currently in the queue.
 * @return The number of elements currently in the queue.
 */
public int size() {
  lock.lock();
  try {
    return elements.size();
  } finally {
    lock.unlock();
  }
}

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

@Override
public <T> boolean tryPut(StreamElementQueueEntry<T> streamElementQueueEntry) throws InterruptedException {
  lock.lockInterruptibly();
  try {
    if (queue.size() < capacity) {
      addEntry(streamElementQueueEntry);
      LOG.debug("Put element into ordered stream element queue. New filling degree " +
        "({}/{}).", queue.size(), capacity);
      return true;
    } else {
      LOG.debug("Failed to put element into ordered stream element queue because it " +
        "was full ({}/{}).", queue.size(), capacity);
      return false;
    }
  } finally {
    lock.unlock();
  }
}

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

@Override
public <T> void put(StreamElementQueueEntry<T> streamElementQueueEntry) throws InterruptedException {
  lock.lockInterruptibly();
  try {
    while (queue.size() >= capacity) {
      notFull.await();
    }
    addEntry(streamElementQueueEntry);
  } finally {
    lock.unlock();
  }
}

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

@Override
public Collection<StreamElementQueueEntry<?>> values() throws InterruptedException {
  lock.lockInterruptibly();
  try {
    StreamElementQueueEntry<?>[] array = new StreamElementQueueEntry[queue.size()];
    array = queue.toArray(array);
    return Arrays.asList(array);
  } finally {
    lock.unlock();
  }
}

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

private List<T> takeObjects(int elementNum) throws InterruptedException
{
 final List<T> list = new ArrayList<>(elementNum);
 final ReentrantLock lock = this.lock;
 lock.lockInterruptibly();
 try {
  while (objects.size() < elementNum) {
   notEnough.await();
  }
  for (int i = 0; i < elementNum; i++) {
   list.add(objects.pop());
  }
  return list;
 }
 finally {
  lock.unlock();
 }
}

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

private List<T> pollObjects(int elementNum) throws InterruptedException
{
 final List<T> list = new ArrayList<>(elementNum);
 final ReentrantLock lock = this.lock;
 lock.lockInterruptibly();
 try {
  if (objects.size() < elementNum) {
   return Collections.emptyList();
  } else {
   for (int i = 0; i < elementNum; i++) {
    list.add(objects.pop());
   }
   return list;
  }
 }
 finally {
  lock.unlock();
 }
}

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

private void offer(T theObject)
 {
  final ReentrantLock lock = this.lock;
  lock.lock();
  try {
   if (objects.size() < maxSize) {
    objects.push(theObject);
    notEnough.signal();
   } else {
    throw new ISE("Cannot exceed pre-configured maximum size");
   }
  }
  finally {
   lock.unlock();
  }
 }
}

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

@Override
public AsyncResult poll() throws InterruptedException {
  lock.lockInterruptibly();
  try {
    while (queue.isEmpty() || !queue.peek().isDone()) {
      headIsCompleted.await();
    }
    notFull.signalAll();
    LOG.debug("Polled head element from ordered stream element queue. New filling degree " +
      "({}/{}).", queue.size() - 1, capacity);
    return queue.poll();
  } finally {
    lock.unlock();
  }
}

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

@Override
public AsyncResult peekBlockingly() throws InterruptedException {
  lock.lockInterruptibly();
  try {
    while (queue.isEmpty() || !queue.peek().isDone()) {
      headIsCompleted.await();
    }
    LOG.debug("Peeked head element from ordered stream element queue with filling degree " +
      "({}/{}).", queue.size(), capacity);
    return queue.peek();
  } finally {
    lock.unlock();
  }
}

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

private void limitFailedBuffersSize()
{
 if (failedBuffers.size() >= config.getBatchQueueSizeLimit()) {
  failedBuffers.removeFirst();
  approximateFailedBuffersCount.decrementAndGet();
  droppedBuffers.incrementAndGet();
  log.error(
    "failedBuffers queue size reached the limit [%d], dropping the oldest failed buffer",
    config.getBatchQueueSizeLimit()
  );
 }
}

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

@Override
void handleClose() {
 if (pendingPushes.remove(this)) {
  completionHandler.fail("Push reset by client");
 } else {
  concurrentStreams--;
  while ((maxConcurrentStreams == null || concurrentStreams < maxConcurrentStreams) && pendingPushes.size() > 0) {
   Push push = pendingPushes.pop();
   concurrentStreams++;
   context.runOnContext(v -> {
    push.complete();
   });
  }
  response.handleClose();
 }
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public void finishingComposite(CompositionDefinition compositionDefinition) {
  // No need to pop anything here; it will be popped by
  // #finishingAttribute, #finishingCollectionElements, #finishingCollectionIndex, or #finishingEntityIdentifier
  log.tracef(
      "%s Finishing composite : %s",
      StringHelper.repeat( "<<", fetchSourceStack.size() ),
      compositionDefinition.getName()
  );
}

代码示例来源:origin: hibernate/hibernate-orm

@Override
public void associationKeyRegistered(AssociationKey associationKey) {
  // todo : use this information to maintain a map of AssociationKey->FetchSource mappings (associationKey + current FetchSource stack entry)
  //		that mapping can then be used in #foundCircularAssociationKey to build the proper BiDirectionalEntityFetch
  //		based on the mapped owner
  log.tracef(
      "%s Registering AssociationKey : %s -> %s",
      StringHelper.repeat( "..", fetchSourceStack.size() ),
      associationKey,
      currentSource()
  );
  fetchedAssociationKeySourceMap.put( associationKey, currentSource() );
}

相关文章

微信公众号

最新文章

更多