本文整理了Java中java.util.ArrayDeque.addFirst()
方法的一些代码示例,展示了ArrayDeque.addFirst()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArrayDeque.addFirst()
方法的具体详情如下:
包路径:java.util.ArrayDeque
类名称:ArrayDeque
方法名:addFirst
[英]Inserts the specified element at the front of this deque.
[中]将指定的元素插入此三角形的前面。
代码示例来源:origin: robovm/robovm
/**
* Inserts the specified element at the front of this deque.
*
* @param e the element to add
* @return <tt>true</tt> (as specified by {@link Deque#offerFirst})
* @throws NullPointerException if the specified element is null
*/
public boolean offerFirst(E e) {
addFirst(e);
return true;
}
代码示例来源:origin: robovm/robovm
/**
* Pushes an element onto the stack represented by this deque. In other
* words, inserts the element at the front of this deque.
*
* <p>This method is equivalent to {@link #addFirst}.
*
* @param e the element to push
* @throws NullPointerException if the specified element is null
*/
public void push(E e) {
addFirst(e);
}
代码示例来源:origin: netty/netty
private void addFirst(ByteBuf buf, ChannelFutureListener listener) {
if (listener != null) {
bufAndListenerPairs.addFirst(listener);
}
bufAndListenerPairs.addFirst(buf);
incrementReadableBytes(buf.readableBytes());
}
代码示例来源:origin: redisson/redisson
private void addFirst(ByteBuf buf, ChannelFutureListener listener) {
if (listener != null) {
bufAndListenerPairs.addFirst(listener);
}
bufAndListenerPairs.addFirst(buf);
incrementReadableBytes(buf.readableBytes());
}
代码示例来源:origin: wildfly/wildfly
private void addFirst(ByteBuf buf, ChannelFutureListener listener) {
if (listener != null) {
bufAndListenerPairs.addFirst(listener);
}
bufAndListenerPairs.addFirst(buf);
incrementReadableBytes(buf.readableBytes());
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public void addFirst(E e) {
boolean contains, first = false;
if ((contains = items.contains(e)) && !(first = getFirst().equals(e)))
remove(e);
if (!contains)
items.add(e);
if (!first)
super.addFirst(e);
}
代码示例来源:origin: hibernate/hibernate-orm
private void pushToStack(ExpandingFetchSource fetchSource) {
log.trace( "Pushing fetch source to stack : " + fetchSource );
propertyPathStack.push( fetchSource.getPropertyPath() );
fetchSourceStack.addFirst( fetchSource );
}
代码示例来源:origin: hibernate/hibernate-orm
private void pushToCollectionStack(CollectionReference collectionReference) {
log.trace( "Pushing collection reference to stack : " + collectionReference );
propertyPathStack.push( collectionReference.getPropertyPath() );
collectionReferenceStack.addFirst( collectionReference );
}
代码示例来源:origin: prestodb/presto
childPartition.addFirst(value);
partitionValues.add(childPartition);
代码示例来源:origin: hibernate/hibernate-orm
public void push(PropertyPath path) {
pathStack.addFirst( path );
MDC.put( MDC_KEY, extractFullPath( path ) );
}
代码示例来源:origin: redisson/redisson
private void sendAllValid(final ChannelHandlerContext ctx, final PerChannel perChannel, final long now) {
// write operations need synchronization
synchronized (perChannel) {
ToSend newToSend = perChannel.messagesQueue.pollFirst();
for (; newToSend != null; newToSend = perChannel.messagesQueue.pollFirst()) {
if (newToSend.relativeTimeAction <= now) {
long size = newToSend.size;
trafficCounter.bytesRealWriteFlowControl(size);
perChannel.queueSize -= size;
queuesSize.addAndGet(-size);
ctx.write(newToSend.toSend, newToSend.promise);
perChannel.lastWriteTimestamp = now;
} else {
perChannel.messagesQueue.addFirst(newToSend);
break;
}
}
if (perChannel.messagesQueue.isEmpty()) {
releaseWriteSuspended(ctx);
}
}
ctx.flush();
}
}
代码示例来源:origin: redisson/redisson
private void sendAllValid(final ChannelHandlerContext ctx, final PerChannel perChannel, final long now) {
// write operations need synchronization
synchronized (perChannel) {
ToSend newToSend = perChannel.messagesQueue.pollFirst();
for (; newToSend != null; newToSend = perChannel.messagesQueue.pollFirst()) {
if (newToSend.relativeTimeAction <= now) {
long size = newToSend.size;
trafficCounter.bytesRealWriteFlowControl(size);
perChannel.channelTrafficCounter.bytesRealWriteFlowControl(size);
perChannel.queueSize -= size;
queuesSize.addAndGet(-size);
ctx.write(newToSend.toSend, newToSend.promise);
perChannel.lastWriteTimestamp = now;
} else {
perChannel.messagesQueue.addFirst(newToSend);
break;
}
}
if (perChannel.messagesQueue.isEmpty()) {
releaseWriteSuspended(ctx);
}
}
ctx.flush();
}
代码示例来源:origin: redisson/redisson
private void sendAllValid(final ChannelHandlerContext ctx, final long now) {
// write order control
synchronized (this) {
ToSend newToSend = messagesQueue.pollFirst();
for (; newToSend != null; newToSend = messagesQueue.pollFirst()) {
if (newToSend.relativeTimeAction <= now) {
long size = calculateSize(newToSend.toSend);
trafficCounter.bytesRealWriteFlowControl(size);
queueSize -= size;
ctx.write(newToSend.toSend, newToSend.promise);
} else {
messagesQueue.addFirst(newToSend);
break;
}
}
if (messagesQueue.isEmpty()) {
releaseWriteSuspended(ctx);
}
}
ctx.flush();
}
代码示例来源:origin: aNNiMON/Lightweight-Stream-API
@Override
public Stream<T> apply(Stream<T> stream) {
final Iterator<? extends T> iterator = stream.iterator();
final ArrayDeque<T> deque = new ArrayDeque<T>();
while (iterator.hasNext()) {
deque.addFirst(iterator.next());
}
return Stream.of(deque.iterator());
}
}
代码示例来源:origin: lettuce-io/lettuce-core
/**
* @see io.netty.channel.ChannelInboundHandlerAdapter#userEventTriggered(io.netty.channel.ChannelHandlerContext, Object)
*/
@Override
public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
if (evt == EnableAutoRead.INSTANCE) {
channel.config().setAutoRead(true);
} else if (evt instanceof Reset) {
reset();
} else if (evt instanceof PingBeforeActivate) {
PingBeforeActivate pba = (PingBeforeActivate) evt;
stack.addFirst(pba.getCommand());
ctx.writeAndFlush(pba.getCommand());
return;
}
super.userEventTriggered(ctx, evt);
}
代码示例来源:origin: openzipkin/brave
/**
* Returns the {@link Tracer#nextSpan()} or null if {@link #CURRENT_TRACER} and tracing isn't
* available.
*/
@Nullable public Span next() {
Tracer tracer = tracer();
if (tracer == null) return null;
Span next = tracer.nextSpan();
Object[] spanAndScope = {next, tracer.withSpanInScope(next)};
getCurrentSpanInScopeStack().addFirst(spanAndScope);
return next;
}
代码示例来源:origin: openzipkin/brave
/**
* Returns the {@link Tracer#nextSpan(TraceContextOrSamplingFlags)} or null if {@link
* #CURRENT_TRACER} and tracing isn't available.
*/
@Nullable public Span next(TraceContextOrSamplingFlags extracted) {
Tracer tracer = tracer();
if (tracer == null) return null;
Span next = tracer.nextSpan(extracted);
Object[] spanAndScope = {next, tracer.withSpanInScope(next)};
getCurrentSpanInScopeStack().addFirst(spanAndScope);
return next;
}
代码示例来源:origin: netty/netty
if (entryBuffer.readableBytes() > bytes) {
bufAndListenerPairs.addFirst(entryBuffer);
if (bytes > 0) {
代码示例来源:origin: apache/flume
public void putFirstOverflow(Integer eventCount) {
if ((queue.peekFirst() == null) || queue.getFirst().intValue() > 0) {
queue.addFirst(new MutableInteger(-eventCount));
} else {
queue.getFirst().add(-eventCount);
}
overflowCounter += eventCount;
}
代码示例来源:origin: apache/flume
public void putFirstPrimary(Integer eventCount) {
if ((queue.peekFirst() == null) || queue.getFirst().intValue() < 0) {
queue.addFirst(new MutableInteger(eventCount));
} else {
queue.getFirst().add(eventCount);
}
}
内容来源于网络,如有侵权,请联系作者删除!