当前位置: 首页>>代码示例>>Java>>正文


Java Deque.offerFirst方法代码示例

本文整理汇总了Java中java.util.Deque.offerFirst方法的典型用法代码示例。如果您正苦于以下问题:Java Deque.offerFirst方法的具体用法?Java Deque.offerFirst怎么用?Java Deque.offerFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Deque的用法示例。


在下文中一共展示了Deque.offerFirst方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: testOfferFirstOrigin

import java.util.Deque; //导入方法依赖的package包/类
@Test
public void testOfferFirstOrigin() {
    Deque<Integer> queue = new ArrayDeque<Integer>();
    queue.offerFirst(1);
    queue.offerFirst(2);
    queue.offerFirst(3);

    assertThat(queue).containsExactly(3, 2, 1);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:10,代码来源:RedissonDequeTest.java

示例4: handleEnter

import java.util.Deque; //导入方法依赖的package包/类
public static final Map<Object,Object> handleEnter(Map<Object,Object> context,
                                                   Deque<IInterceptor> queue,
                                                   Deque<IInterceptor> stack,
                                                   List<Predicate<Map<Object,Object>>> terminators) {

    //NOTE: It's assumed the queue has been null-checked by this point
    while (queue.size() > 0) {

        IInterceptor interceptor = queue.pollFirst();
        if (interceptor == null) {
            context.remove("dais.queue");
            return handleLeave(context, stack);
        }
        stack.offerFirst(interceptor);

        try {
            context = IInterceptor.enter(interceptor, context);

            if (context.get("error") != null) {
                return handleError(context, interceptor, stack);
            }
        } catch (Throwable t) {
            context.put("error", t);
            return handleError(context, interceptor, stack);
        }

        if (terminators != null) {
            for (Predicate p : terminators) {
                if (p != null && p.test(context)) {
                    context.remove("dais.queue");
                    return handleLeave(context, stack);
                }
            }
        }
    }
    return context;

}
 
开发者ID:ohpauleez,项目名称:dais,代码行数:39,代码来源:Chain.java

示例5: handleArrayEnter

import java.util.Deque; //导入方法依赖的package包/类
public static final Map<Object,Object> handleArrayEnter(Map<Object,Object> context,
                                                        IInterceptor[] queue,
                                                        Deque<IInterceptor> stack,
                                                        List<Predicate<Map<Object,Object>>> terminators) {

    //NOTE: It's assumed the queue has been null-checked by this point
    for(IInterceptor interceptor : queue) {
        if (interceptor == null) {
            context.remove("dais.queue");
            return handleLeave(context, stack);
        }
        stack.offerFirst(interceptor);

        try {
            context = IInterceptor.enter(interceptor, context);

            if (context.get("error") != null) {
                return handleError(context, interceptor, stack);
            }
        } catch (Throwable t) {
            context.put("error", t);
            return handleError(context, interceptor, stack);
        }

        if (terminators != null) {
            for (Predicate p : terminators) {
                if (p != null && p.test(context)) {
                    context.remove("dais.queue");
                    return handleLeave(context, stack);
                }
            }
        }
    }
    return context;
}
 
开发者ID:ohpauleez,项目名称:dais,代码行数:36,代码来源:Chain.java

示例6: exploreChildrenDFS

import java.util.Deque; //导入方法依赖的package包/类
private void exploreChildrenDFS(
    Map<TypeElement, Set<TypeElement>> dependencies,
    TypeElement element,
    Deque<TypeElement> stack,
    Set<TypeElement> visited
) {
    visited.add(element);
    for (TypeElement childVertex : dependencies.get(element)) {
        if (!visited.contains(childVertex)) {
            exploreChildrenDFS(dependencies, childVertex, stack, visited);
        }
    }
    stack.offerFirst(element);
}
 
开发者ID:foodora,项目名称:android-auto-mapper,代码行数:15,代码来源:DependencySolver.java


注:本文中的java.util.Deque.offerFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。