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

x33g5p2x  于2022-01-28 转载在 其他  
字(8.0k)|赞(0)|评价(0)|浏览(271)

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

ArrayDeque.addLast介绍

[英]Inserts the specified element at the end of this deque.

This method is equivalent to #add.
[中]在此数据块的末尾插入指定的元素。
此方法相当于#add。

代码示例

代码示例来源:origin: google/google-java-format

/** Start to build a {@code DocBuilder}. */
public DocBuilder() {
 stack.addLast(base);
}

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

/**
 * Inserts the specified element at the end of this deque.
 *
 * @param e the element to add
 * @return <tt>true</tt> (as specified by {@link Deque#offerLast})
 * @throws NullPointerException if the specified element is null
 */
public boolean offerLast(E e) {
  addLast(e);
  return true;
}

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

/**
 * Inserts the specified element at the end of this deque.
 *
 * <p>This method is equivalent to {@link #addLast}.
 *
 * @param e the element to add
 * @return <tt>true</tt> (as specified by {@link Collection#add})
 * @throws NullPointerException if the specified element is null
 */
public boolean add(E e) {
  addLast(e);
  return true;
}

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

@Override
public void execute(@Nonnull Runnable command) {
  synchronized (queuedRunnables) {
    queuedRunnables.addLast(command);
  }
}

代码示例来源:origin: org.apache.lucene/lucene-core

public void reuse(ByteBuffer buffer) {
  buffer.rewind();
  reuse.addLast(buffer);
 }
}

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

/** {@inheritDoc} */
@Override public void addLast(E e) {
  if (!items.contains(e)) {
    super.addLast(e);
    items.add(e);
  }
}

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

/**
 * Adds the element to the queue, or fails with an exception, if the queue is closed.
 * Checking whether the queue is open and adding the element is one atomic operation.
 *
 * @param element The element to add.
 * @throws IllegalStateException Thrown, if the queue is closed.
 */
public void add(E element) throws IllegalStateException {
  requireNonNull(element);
  lock.lock();
  try {
    if (open) {
      elements.addLast(element);
      if (elements.size() == 1) {
        nonEmpty.signalAll();
      }
    } else {
      throw new IllegalStateException("queue is closed");
    }
  } finally {
    lock.unlock();
  }
}

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

/**
 * Tries to add an element to the queue, if the queue is still open. Checking whether the queue
 * is open and adding the element is one atomic operation.
 *
 * <p>Unlike the {@link #add(Object)} method, this method never throws an exception,
 * but only indicates via the return code if the element was added or the
 * queue was closed.
 *
 * @param element The element to add.
 * @return True, if the element was added, false if the queue was closes.
 */
public boolean addIfOpen(E element) {
  requireNonNull(element);
  lock.lock();
  try {
    if (open) {
      elements.addLast(element);
      if (elements.size() == 1) {
        nonEmpty.signalAll();
      }
    }
    return open;
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: google/google-java-format

/**
 * Open a new {@link Doc.Level}.
 *
 * @param plusIndent the extra indent for the {@link Doc.Level}
 */
void open(Indent plusIndent) {
 Doc.Level level = Doc.Level.make(plusIndent);
 stack.addLast(level);
}

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

/**
 * @param req Write request.
 * @return {@code False} if queue limit is exceeded.
 */
public boolean add(SessionWriteRequest req) {
  assert req != null;
  if (!req.skipRecovery()) {
    if (resendCnt == 0) {
      msgReqs.addLast(req);
      sentCnt++;
      return msgReqs.size() < queueLimit;
    }
    else
      resendCnt--;
  }
  return true;
}

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

private void emitLargeEvent(byte[] eventBytes)
{
 byte[] buffer = acquireBuffer();
 int bufferOffset = batchingStrategy.writeBatchStart(buffer);
 System.arraycopy(eventBytes, 0, buffer, bufferOffset, eventBytes.length);
 bufferOffset += eventBytes.length;
 bufferOffset = batchingStrategy.writeBatchEnd(buffer, bufferOffset);
 if (sendWithRetries(buffer, bufferOffset, 1, true)) {
  buffersToReuse.add(buffer);
  approximateBuffersToReuseCount.incrementAndGet();
 } else {
  limitFailedBuffersSize();
  failedBuffers.addLast(new FailedBuffer(buffer, bufferOffset, 1));
  approximateFailedBuffersCount.incrementAndGet();
 }
}

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

/**
 * Add the given {@link StreamElementQueueEntry} to the queue. Additionally, this method
 * registers a onComplete callback which is triggered once the given queue entry is completed.
 *
 * @param streamElementQueueEntry to be inserted
 * @param <T> Type of the stream element queue entry's result
 */
private <T> void addEntry(StreamElementQueueEntry<T> streamElementQueueEntry) {
  assert(lock.isHeldByCurrentThread());
  queue.addLast(streamElementQueueEntry);
  streamElementQueueEntry.onComplete(
    (StreamElementQueueEntry<T> value) -> {
      try {
        onCompleteHandler(value);
      } catch (InterruptedException e) {
        // we got interrupted. This indicates a shutdown of the executor
        LOG.debug("AsyncBufferEntry could not be properly completed because the " +
          "executor thread has been interrupted.", e);
      } catch (Throwable t) {
        operatorActions.failOperator(new Exception("Could not complete the " +
          "stream element queue entry: " + value + '.', t));
      }
    },
    executor);
}

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

@Override
public final void queueInputBuffer(I inputBuffer) throws E {
 synchronized (lock) {
  maybeThrowException();
  Assertions.checkArgument(inputBuffer == dequeuedInputBuffer);
  queuedInputBuffers.addLast(inputBuffer);
  maybeNotifyDecodeLoop();
  dequeuedInputBuffer = null;
 }
}

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

@Override
public void snapshotState(FunctionSnapshotContext context) throws Exception {
  Preconditions.checkState(this.checkpointedState != null,
    "The " + getClass().getSimpleName() + " has not been properly initialized.");
  if (LOG.isDebugEnabled()) {
    LOG.debug("{} checkpointing: Messages: {}, checkpoint id: {}, timestamp: {}",
      idsForCurrentCheckpoint, context.getCheckpointId(), context.getCheckpointTimestamp());
  }
  pendingCheckpoints.addLast(new Tuple2<>(context.getCheckpointId(), idsForCurrentCheckpoint));
  idsForCurrentCheckpoint = new HashSet<>(64);
  this.checkpointedState.clear();
  this.checkpointedState.add(SerializedCheckpointData.fromDeque(pendingCheckpoints, idSerializer));
}

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

private void updatePlaybackInfo(
  PlaybackInfo playbackInfo,
  boolean positionDiscontinuity,
  @Player.DiscontinuityReason int positionDiscontinuityReason,
  @Player.TimelineChangeReason int timelineChangeReason,
  boolean seekProcessed,
  boolean playWhenReadyChanged) {
 boolean isRunningRecursiveListenerNotification = !pendingPlaybackInfoUpdates.isEmpty();
 pendingPlaybackInfoUpdates.addLast(
   new PlaybackInfoUpdate(
     playbackInfo,
     /* previousPlaybackInfo= */ this.playbackInfo,
     listeners,
     trackSelector,
     positionDiscontinuity,
     positionDiscontinuityReason,
     timelineChangeReason,
     seekProcessed,
     playWhenReady,
     playWhenReadyChanged));
 // Assign playback info immediately such that all getters return the right values.
 this.playbackInfo = playbackInfo;
 if (isRunningRecursiveListenerNotification) {
  return;
 }
 while (!pendingPlaybackInfoUpdates.isEmpty()) {
  pendingPlaybackInfoUpdates.peekFirst().notifyListeners();
  pendingPlaybackInfoUpdates.removeFirst();
 }
}

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

@Override
void submitWrite(final ChannelHandlerContext ctx, final Object msg,
    final long size, final long delay, final long now,
    final ChannelPromise promise) {
  final ToSend newToSend;
  // write order control
  synchronized (this) {
    if (delay == 0 && messagesQueue.isEmpty()) {
      trafficCounter.bytesRealWriteFlowControl(size);
      ctx.write(msg, promise);
      return;
    }
    newToSend = new ToSend(delay + now, msg, promise);
    messagesQueue.addLast(newToSend);
    queueSize += size;
    checkWriteSuspend(ctx, delay, queueSize);
  }
  final long futureNow = newToSend.relativeTimeAction;
  ctx.executor().schedule(new Runnable() {
    @Override
    public void run() {
      sendAllValid(ctx, futureNow);
    }
  }, delay, TimeUnit.MILLISECONDS);
}

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

} else {
 limitFailedBuffersSize();
 failedBuffers.addLast(new FailedBuffer(batch.buffer, bufferEndOffset, eventCount));
 approximateFailedBuffersCount.incrementAndGet();

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

deque.addLast(new Tuple2<Long, Set<T>>(checkpoint.checkpointId, ids));

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

public void putPrimary(Integer eventCount) {
 totalPuts += eventCount;
 if ((queue.peekLast() == null) || queue.getLast().intValue() < 0) {
  queue.addLast(new MutableInteger(eventCount));
 } else {
  queue.getLast().add(eventCount);
 }
}

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

public void putOverflow(Integer eventCount) {
 totalPuts += eventCount;
 if ((queue.peekLast() == null) || queue.getLast().intValue() > 0) {
  queue.addLast(new MutableInteger(-eventCount));
 } else {
  queue.getLast().add(-eventCount);
 }
 overflowCounter += eventCount;
}

相关文章