當前位置: 首頁>>代碼示例>>Java>>正文


Java Deque.offerLast方法代碼示例

本文整理匯總了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());                       
}
 
開發者ID:mkdika,項目名稱:learnjava8,代碼行數:23,代碼來源:TestDeque.java

示例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);
}
 
開發者ID:uber,項目名稱:NullAway,代碼行數:20,代碼來源:NullAwayNativeModels.java

示例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());
}
 
開發者ID:qq1588518,項目名稱:JRediClients,代碼行數:12,代碼來源:RedissonDequeTest.java

示例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));
            }
        }
    };
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:32,代碼來源:OperatorTakeLast.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:7,代碼來源:ConstantTreeAnalyzer.java


注:本文中的java.util.Deque.offerLast方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。