本文整理汇总了Java中java.util.Deque.offerLast方法的典型用法代码示例。如果您正苦于以下问题:Java Deque.offerLast方法的具体用法?Java Deque.offerLast怎么用?Java Deque.offerLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Deque
的用法示例。
在下文中一共展示了Deque.offerLast方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import java.util.Deque; //导入方法依赖的package包/类
public static void main(String[] args) {
Deque<Integer> deque = new LinkedList<>();
// OFFER - add some data into queue
deque.offer(5);
deque.offer(4);
deque.offer(2);
deque.offerFirst(1);
deque.offerLast(9);
System.out.println("After offer data. Size: " + deque.size()+", content: " + deque.toString());
// PEEK - view data from first or last, without remove it
System.out.println("Peek First is " + deque.peekFirst()+", Peek Last is "
+ deque.peekLast()+", Peek is "+ deque.peek());
// POLL - removeing, head or tail data from queue
System.out.println("Poll head data is " + deque.pollFirst()+
", poll last data is " + deque.pollLast()+
", poll is " + deque.poll()+
", content: " + deque.toString());
}
示例2: dequeStuff
import java.util.Deque; //导入方法依赖的package包/类
static void dequeStuff() {
Deque<Object> d = new ArrayDeque<>();
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.add(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.addFirst(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.addLast(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.offerFirst(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.offerLast(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.offer(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.push(null);
// BUG: Diagnostic contains: passing @Nullable parameter 'null' where @NonNull is required
d.toArray(null);
}
示例3: testOfferLastOrigin
import java.util.Deque; //导入方法依赖的package包/类
@Test
public void testOfferLastOrigin() {
Deque<Integer> queue = new ArrayDeque<Integer>();
queue.offerLast(1);
queue.offerLast(2);
queue.offerLast(3);
assertThat(queue).containsExactly(1, 2, 3);
Assert.assertEquals((Integer)1, queue.poll());
}
示例4: call
import java.util.Deque; //导入方法依赖的package包/类
public Subscriber<? super T> call(Subscriber<? super T> subscriber) {
final Deque<Object> deque = new ArrayDeque();
final NotificationLite<T> notification = NotificationLite.instance();
final TakeLastQueueProducer<T> producer = new TakeLastQueueProducer(notification, deque, subscriber);
subscriber.setProducer(producer);
final Subscriber<? super T> subscriber2 = subscriber;
return new Subscriber<T>(subscriber) {
public void onStart() {
request(Long.MAX_VALUE);
}
public void onCompleted() {
deque.offer(notification.completed());
producer.startEmitting();
}
public void onError(Throwable e) {
deque.clear();
subscriber2.onError(e);
}
public void onNext(T value) {
if (OperatorTakeLast.this.count != 0) {
if (deque.size() == OperatorTakeLast.this.count) {
deque.removeFirst();
}
deque.offerLast(notification.next(value));
}
}
};
}
示例5: filteredPush
import java.util.Deque; //导入方法依赖的package包/类
private void filteredPush(DebugContext debug, Deque<AbstractBlockBase<?>> worklist, AbstractBlockBase<?> block) {
if (isMarked(block)) {
debug.log(DebugContext.VERBOSE_LEVEL, "adding %s to the worklist", block);
worklist.offerLast(block);
}
}