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


Java Deque.addLast方法代码示例

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


在下文中一共展示了Deque.addLast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: bfsHelper

import java.util.Deque; //导入方法依赖的package包/类
/**
 * Performs a BFS from a given starting pixel in order to determine the
 * border of the image.
 *
 * @param x the x coordinate of the starting point.
 * @param y the y coordinate of the starting point.
 */
private void bfsHelper(int x, int y) {
  Deque<Point<Integer>> queue = new ArrayDeque<>();
  queue.push(new Point<>(x, y));

  while (!queue.isEmpty()) {
    Point<Integer> popped = queue.pollLast();
    borderPoints.add(popped);

    for (int i = -1; i <= 1; i++) {
      for (int j = -1; j <= 1; j++) {
        Point<Integer> next = new Point<>(popped.getX() + i, popped.getY() + j);

        if (picture.contains(next) &&
            borderColor.sameColor(picture.getPixel(next.getX(), next.getY()),
                BLACK_SENSITIVITY) && !visited[next.getX()][next.getY()]) {
            visited[next.getX()][next.getY()] = true;
            queue.addLast(next);
        }
      }
    }
  }
}
 
开发者ID:catalincraciun,项目名称:scancode,代码行数:30,代码来源:CornerAnalyzer.java

示例3: visitDepthFirst

import java.util.Deque; //导入方法依赖的package包/类
private void visitDepthFirst(AST ast) {
	if ( ast == null ) {
		return;
	}
	Deque<AST> stack = new ArrayDeque<AST>();
	stack.addLast( ast );
	while ( !stack.isEmpty() ) {
		ast = stack.removeLast();
		strategy.visit( ast );
		if ( ast.getNextSibling() != null ) {
			stack.addLast( ast.getNextSibling() );
		}
		if ( ast.getFirstChild() != null ) {
			stack.addLast( ast.getFirstChild() );
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:18,代码来源:NodeTraverser.java

示例4: createLoads

import java.util.Deque; //导入方法依赖的package包/类
private void createLoads(DefUseTree tree, ConstantTree constTree, AbstractBlockBase<?> startBlock) {
    Deque<AbstractBlockBase<?>> worklist = new ArrayDeque<>();
    worklist.add(startBlock);
    while (!worklist.isEmpty()) {
        AbstractBlockBase<?> block = worklist.pollLast();
        if (constTree.get(Flags.CANDIDATE, block)) {
            constTree.set(Flags.MATERIALIZE, block);
            // create and insert load
            insertLoad(tree.getConstant(), tree.getVariable().getValueKind(), block, constTree.getCost(block).getUsages());
        } else {
            AbstractBlockBase<?> dominated = block.getFirstDominated();
            while (dominated != null) {
                if (constTree.isMarked(dominated)) {
                    worklist.addLast(dominated);
                }
                dominated = dominated.getDominatedSibling();
            }
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ConstantLoadOptimization.java

示例5: testAddLastOrigin

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

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

示例6: generatePath

import java.util.Deque; //导入方法依赖的package包/类
public Deque<DistanceFrom> generatePath() {

        List<FutureTask<DistanceFrom>> effectiveDistanceFromStart = calculateDistanceFromStart(
                initialPosition,
                getInRange(
                        initialPosition,
                        MIN_DISTANCE_FIRST_HOP,
                        MAX_DISTANCE_FIRST_HOP
                ));
        Collections.shuffle(effectiveDistanceFromStart); // Randomizing the points...

        for (FutureTask<DistanceFrom> distanceFromFutureTask : effectiveDistanceFromStart) {
            Deque<DistanceFrom> path = new ArrayDeque<>();
            try {
                DistanceFrom distance = distanceFromFutureTask.get();
                Map<LatLng, Boolean> visitedTable = new HashMap<>();

                visitedTable.put(distance.end, true);

                path.addLast(distance);
                path.addAll(pathChooser(distance,
                        maxDistance - (distance.distance/1000),
                        visitedTable,
                        5));
                if (path.size() >= HOP_MIN_NUM) {
                    return path;
                }
            } catch (InterruptedException | ExecutionException  e) {
                e.printStackTrace();
            }
        }
        return new ArrayDeque<>();
    }
 
开发者ID:Augugrumi,项目名称:SpaceRace,代码行数:34,代码来源:PathCreator.java

示例7: printFromTopToBottom

import java.util.Deque; //导入方法依赖的package包/类
public void printFromTopToBottom(TreeNode root) {
    if (root == null) return;
    Deque<TreeNode> queue = new ArrayDeque<>();
    queue.addLast(root);

    while (!queue.isEmpty()) {
        TreeNode node = queue.pop();
        System.out.print(node.val + " ");
        if (node.left != null)
            queue.addLast(node.left);
        if (node.right != null)
            queue.addLast(node.right);
    }
}
 
开发者ID:JoeZ-EE,项目名称:Aim2Offer,代码行数:15,代码来源:023_BinaryTreeInRowOrder.java

示例8: refreshMeter

import java.util.Deque; //导入方法依赖的package包/类
void refreshMeter() {
    BaseComponent label;
    ChatColor color = METER_COLORS.get(stamina);

    if(color != null) {
        int segments = METER_COLORS.asMapOfRanges().size();
        Deque<BaseComponent> parts = new ArrayDeque<>(segments * 2 + 3);

        parts.add(SPACE);
        parts.add(new TranslatableComponent("stamina.label"));
        parts.add(SPACE);

        for(Map.Entry<Range<Double>, ChatColor> entry : METER_COLORS.asMapOfRanges().entrySet()) {
            int length = (int) (METER_SCALE * (Numbers.clamp(stamina, entry.getKey()) - entry.getKey().lowerEndpoint()));
            Component segment = new Component(Strings.repeat("\u23d0", length), entry.getValue());
            parts.addFirst(segment);
            parts.addLast(segment);
        }

        label = new Component(color).extra(parts);
    } else {
        StaminaMutator cause = getDepletionCause();
        if(cause != null) {
            label = new Component(new TranslatableComponent("stamina.depletedFromMutator",
                                                            new Component(cause.getDescription(), ChatColor.AQUA)),
                                  ChatColor.RED);
        } else {
            label = new Component(new TranslatableComponent("stamina.depleted"), ChatColor.RED);
        }
    }

    player.sendHotbarMessage(label);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:34,代码来源:PlayerStaminaState.java

示例9: print

import java.util.Deque; //导入方法依赖的package包/类
public void print(TreeNode root) {
	
	if (root == null)
		return;
	
	Deque<TreeNode> queue = new ArrayDeque<>();
	queue.addLast(root);
	int nextLevel = 0;
	int toBePrinted = 1;
	while (!queue.isEmpty()) {
		TreeNode node = queue.getFirst();
		System.out.print(node.val + " ");
		if (node.left != null) {
			queue.addLast(node.left);
			++nextLevel;
		}
		if (node.right != null) {
			queue.addLast(node.right);
			++nextLevel;
		}
		
		queue.pop();
		--toBePrinted;
		if (toBePrinted == 0) {
			System.out.println();
			toBePrinted = nextLevel;
			nextLevel = 0;
		}
	}
}
 
开发者ID:JoeZ-EE,项目名称:Aim2Offer,代码行数:31,代码来源:060_PrintTreesInLines.java

示例10: getArrayIndices

import java.util.Deque; //导入方法依赖的package包/类
/**
 * Returns all array indices for the given expression, e.g. given {@code foo[0][0]} returns the
 * expressions for {@code [0][0]}.
 */
private Deque<ExpressionTree> getArrayIndices(ExpressionTree expression) {
    Deque<ExpressionTree> indices = new ArrayDeque<>();
    while (expression instanceof ArrayAccessTree) {
        ArrayAccessTree array = (ArrayAccessTree) expression;
        indices.addLast(array.getIndex());
        expression = array.getExpression();
    }
    return indices;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:14,代码来源:JavaInputAstVisitor.java

示例11: with

import java.util.Deque; //导入方法依赖的package包/类
public static Context with(Iterable<PathElement> ancestors) {
	Deque<PathElement> ancestorsStack = getAncestors();
	int count = 0;
	for (PathElement ancestor : ancestors) {
		ancestorsStack.addLast(ancestor);
		count++;
	}
	return new Context(count);
}
 
开发者ID:tkob,项目名称:spring-data-gclouddatastore,代码行数:10,代码来源:Context.java

示例12: DFA

import java.util.Deque; //导入方法依赖的package包/类
public<M extends IPredicateMap<P,T,State,M>> DFA(M factory, FSA<T,F,P> automaton, boolean debug) {
    this(factory);
    // Перезапускаем автомат и сохраняем стартовое состояние
    Set<State> old_initial=automaton.initialState();
    // Создаем отображение старых состояний на новые
    Map<Set<State>,State> old2new=new HashMap();
    State new_initial=debug?this.newState(old_initial,automaton):this.newState();
    old2new.put(old_initial,new_initial);
    // Создаем массив состояний, которые мы еще не рассмотрели
    Deque<Set<State>> unprocessed=new ArrayDeque();
    unprocessed.addLast(old_initial);        
    // Перебираем все состояния 
    Set<State> old_states;
    while((old_states=unprocessed.poll())!=null) {
        State active=old2new.get(old_states);
        // и делаем из состояния active все переходы.
        // Получаем все возможные символы для перехода.
        Map<P,Set<State>> old_transitions=DFA.purifyTransitions(automaton.getTransitions(old_states));
        // Маркируем остановочные состояния
        for(F mark: automaton.getMarkers(old_states))
            this.markState(active, mark);
        // Для каждого символа перехода
        for(Map.Entry<P,Set<State>> entry: old_transitions.entrySet()) {
            // Ищем куда ведет переход
            Set<State> old_targets=entry.getValue();
            automaton.doEpsilonTransition(old_targets);
            State target;
            if(old2new.containsKey(old_targets)) target=old2new.get(old_targets);
            else {
                target=debug?this.newState(old_targets,automaton):this.newState();
                old2new.put(old_targets,target);
                // Если состояние новое, то добавляем его в список непроанализированных состояний
                unprocessed.addLast(old_targets);
            };
            // Создаем переход в новом автомате
            this.newTransition(active,target,entry.getKey());
        };
    };
}
 
开发者ID:alepoydes,项目名称:writing-compiler-for-neophytes,代码行数:40,代码来源:DFA.java

示例13: release

import java.util.Deque; //导入方法依赖的package包/类
@Override
public void release(ByteBuffer buffer) {
    buffer.clear();
    Deque<ByteBuffer> bufferQueue = bufferMap.get(buffer.capacity());
    if (bufferQueue == null) {
        // We currently keep a single buffer in flight, so optimise for that case
        bufferQueue = new ArrayDeque<>(1);
        bufferMap.put(buffer.capacity(), bufferQueue);
    }
    bufferQueue.addLast(buffer);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:12,代码来源:BufferSupplier.java

示例14: testInvokePush

import java.util.Deque; //导入方法依赖的package包/类
@Test
public void testInvokePush() throws ScriptException {
    final Deque<Object> l = getListAdapter();
    l.addLast(5);
    assertEquals(l.size(), 5);
    assertEquals(l.getLast(), 5);
    assertEquals(l.getFirst(), 1);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:AddAndRemoveOnListAdapterOutsideOfJavaScriptContextTest.java

示例15: addInterfaces

import java.util.Deque; //导入方法依赖的package包/类
/**
 * Adds all interfaces from this class to the deque of interfaces.
 *
 * @param intfs the deque of interfaces
 * @param cf the ClassFile of this class
 * @throws ConstantPoolException if a constant pool entry cannot be found
 */
void addInterfaces(Deque<String> intfs, ClassFile cf)
        throws ConstantPoolException {
    int count = cf.interfaces.length;
    for (int i = 0; i < count; i++) {
        intfs.addLast(cf.getInterfaceName(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:Scan.java


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