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


Java ArrayDeque.isEmpty方法代码示例

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


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

示例1: floodFill

import java.util.ArrayDeque; //导入方法依赖的package包/类
private Set<EnumFacing> floodFill(int p_178604_1_)
{
    Set<EnumFacing> set = EnumSet.<EnumFacing>noneOf(EnumFacing.class);
    ArrayDeque arraydeque = new ArrayDeque(384);
    arraydeque.add(IntegerCache.getInteger(p_178604_1_));
    this.bitSet.set(p_178604_1_, true);

    while (!arraydeque.isEmpty())
    {
        int i = ((Integer)arraydeque.poll()).intValue();
        this.addEdges(i, set);

        for (EnumFacing enumfacing : EnumFacing.VALUES)
        {
            int j = this.getNeighborIndexAtFace(i, enumfacing);

            if (j >= 0 && !this.bitSet.get(j))
            {
                this.bitSet.set(j, true);
                arraydeque.add(IntegerCache.getInteger(j));
            }
        }
    }

    return set;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:27,代码来源:VisGraph.java

示例2: findDistances

import java.util.ArrayDeque; //导入方法依赖的package包/类
private static void findDistances(Node start) {
    if (start == null) {
        return;
    }
    ArrayDeque<Node> deque = new ArrayDeque<>(); // use deque as a queue
    start.distance = 0;
    deque.add(start);
    while (!deque.isEmpty()) {
        Node curr = deque.remove();
        for (Node neighbor : curr.neighbors) {
            if (neighbor.distance == -1) { // meaning it's unvisited
                neighbor.distance = curr.distance + EDGE_WEIGHT;
                deque.add(neighbor);
            }
        }
    }
}
 
开发者ID:rshaghoulian,项目名称:HackerRank_solutions,代码行数:18,代码来源:Solution.java

示例3: levelOrder1

import java.util.ArrayDeque; //导入方法依赖的package包/类
void levelOrder1(BinaryTreeNode btn) {
	BinaryTreeNode root = btn;
	ArrayDeque<BinaryTreeNode> queue = new ArrayDeque<BinaryTreeNode>();
	if (root == null)
		return;
	//使用offer和poll优于add和remove之处在于它们返回值可以判断成功与否,而不抛出异常
	queue.offer(root);
	while (queue.isEmpty() != true) {
		root = queue.poll();
		printNode(root);
		if (root.leftNode != null)
			queue.offer(root.leftNode);
		if (root.rightNode != null)
			queue.offer(root.rightNode);
	}
}
 
开发者ID:selfconzrr,项目名称:Tree_learning,代码行数:17,代码来源:binaryTree.java

示例4: propagateAdd

import java.util.ArrayDeque; //导入方法依赖的package包/类
private static void propagateAdd(ArrayDeque<LightNode> lightQueue, LightWorldSection w) {
	if (lightQueue.isEmpty())
		return;

	while (!lightQueue.isEmpty()) {
		LightNode n = lightQueue.pop();
		int x = n.x;
		int y = n.y;
		int z = n.z;
		int l = n.l;

		if (l <= 1)
			continue;

		tryPropagateAdd(lightQueue, w, x - 1, y, z, l);
		tryPropagateAdd(lightQueue, w, x + 1, y, z, l);
		tryPropagateAdd(lightQueue, w, x, y, z - 1, l);
		tryPropagateAdd(lightQueue, w, x, y, z + 1, l);
		if (y > 0)
			tryPropagateAdd(lightQueue, w, x, y - 1, z, l);
		tryPropagateAdd(lightQueue, w, x, y + 1, z, l);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:24,代码来源:BlockLight.java

示例5: propagateRemove

import java.util.ArrayDeque; //导入方法依赖的package包/类
private static void propagateRemove(ArrayDeque<LightNode> removeQueue, ArrayDeque<LightNode> addQueue,
		LightWorldSection w) {
	if (removeQueue.isEmpty())
		return;

	while (!removeQueue.isEmpty()) {
		LightNode n = removeQueue.pop();
		int x = n.x;
		int y = n.y;
		int z = n.z;
		int l = n.l;

		if (l <= 1)
			continue;

		tryPropagateRemove(removeQueue, addQueue, w, x - 1, y, z, l);
		tryPropagateRemove(removeQueue, addQueue, w, x + 1, y, z, l);
		tryPropagateRemove(removeQueue, addQueue, w, x, y, z - 1, l);
		tryPropagateRemove(removeQueue, addQueue, w, x, y, z + 1, l);
		if (y > 0)
			tryPropagateRemove(removeQueue, addQueue, w, x, y - 1, z, l);
		tryPropagateRemove(removeQueue, addQueue, w, x, y + 1, z, l);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:25,代码来源:BlockLight.java

示例6: func_178604_a

import java.util.ArrayDeque; //导入方法依赖的package包/类
private Set func_178604_a(int p_178604_1_)
{
    EnumSet enumset = EnumSet.noneOf(EnumFacing.class);
    ArrayDeque arraydeque = new ArrayDeque(384);
    arraydeque.add(IntegerCache.valueOf(p_178604_1_));
    this.field_178612_d.set(p_178604_1_, true);

    while (!arraydeque.isEmpty())
    {
        int i = ((Integer)arraydeque.poll()).intValue();
        this.func_178610_a(i, enumset);

        for (EnumFacing enumfacing : EnumFacing.VALUES)
        {
            int j = this.func_178603_a(i, enumfacing);

            if (j >= 0 && !this.field_178612_d.get(j))
            {
                this.field_178612_d.set(j, true);
                arraydeque.add(IntegerCache.valueOf(j));
            }
        }
    }

    return enumset;
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:27,代码来源:VisGraph.java

示例7: isBalanced

import java.util.ArrayDeque; //导入方法依赖的package包/类
private static boolean isBalanced(String expression, HashMap<Character, Character> map) {
    if ((expression.length() % 2) != 0) {
        return false; // odd length Strings are not balanced
    }        
    ArrayDeque<Character> deque = new ArrayDeque<>(); // use deque as a stack
    for (int i = 0; i < expression.length(); i++) {
        Character ch = expression.charAt(i);
        if (map.containsKey(ch)) {
            deque.push(ch);
        } else if (deque.isEmpty() || ch != map.get(deque.pop())) {
            return false;
        }
    }
    return deque.isEmpty();
}
 
开发者ID:rshaghoulian,项目名称:HackerRank_solutions,代码行数:16,代码来源:Solution.java

示例8: randomTick

import java.util.ArrayDeque; //导入方法依赖的package包/类
@Override
public int randomTick(World world, Area area, final int blockX, final int blockY, final int blockZ, int meta) {
  if (meta == 1) {
    HashSet<BlockReference> checked = new HashSet<BlockReference>();
    ArrayDeque<BlockReference> todo = new ArrayDeque<BlockReference>();
    BlockReference start = new BlockReference().setFromBlockCoordinates(blockX, blockY, blockZ);
    todo.add(start.copy().offset(-1, 0, 0));
    todo.add(start.copy().offset(1, 0, 0));
    todo.add(start.copy().offset(0, -1, 0));
    todo.add(start.copy().offset(0, 1, 0));
    todo.add(start.copy().offset(0, 0, -1));
    todo.add(start.copy().offset(0, 0, 1));
    while (!todo.isEmpty()) {
      BlockReference poll = todo.poll();
      int x = poll.blockX, y = poll.blockY, z = poll.blockZ;
      Area a = area;
      if (x < 0 || x >= Area.SIZE_BLOCKS || z < 0 || z >= Area.SIZE_BLOCKS) {
        a = area.neighbourBlockCoordinates(x + area.minBlockX, z + area.minBlockZ);
        if (a == null) return meta; //otherwise leaves may decay if area containing log is not loaded
        x = x + area.minBlockX - a.minBlockX;
        z = z + area.minBlockZ - a.minBlockZ;
      }
      if (y < 0 || y > a.maxY) continue;
      Block b = a.getBlock(x, y, z);
      if (b == Blocks.leaves) {
        add(checked, todo, start, poll, -1, 0, 0);
        add(checked, todo, start, poll, 1, 0, 0);
        add(checked, todo, start, poll, 0, -1, 0);
        add(checked, todo, start, poll, 0, 1, 0);
        add(checked, todo, start, poll, 0, 0, -1);
        add(checked, todo, start, poll, 0, 0, 1);
      } else if (b == Blocks.log) {
        return meta;
      }
    }
    area.setBlock(null, blockX, blockY, blockZ, 0);
    dropItems(Cubes.getServer().world, blockX + area.minBlockX, blockY, blockZ + area.minBlockZ, meta);
  }
  return meta;
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:41,代码来源:BlockLeaves.java

示例9: LevelOrder

import java.util.ArrayDeque; //导入方法依赖的package包/类
static void LevelOrder(BSTNode root){
    if(root==null)  return;
    ArrayDeque<BSTNode> q = new ArrayDeque<BSTNode>();
    q.add(root);
    while(!q.isEmpty()){
        BSTNode n = q.remove();
        System.out.print(n.data+" ");
        if(n.left!=null)	q.add(n.left);
        if(n.right!=null)	q.add(n.right);
    }
    System.out.println();
}
 
开发者ID:kevalmorabia97,项目名称:Data-Structures-Implementations-in-JAVA,代码行数:13,代码来源:BinarySerchTree.java

示例10: restoreAllInfo

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * @param pathRecord 点击的展开路径记录
 * 通过路径直接恢复视图序列
 */
private void restoreAllInfo(ArrayDeque<MenuItem> pathRecord) {
    mPathRecord.clear();
    while (!pathRecord.isEmpty()) {
        mCurMenuItem = pathRecord.getLast();
        addOneLevel();
        pathRecord.removeLast();
    }

}
 
开发者ID:nowandfurure,项目名称:richeditor,代码行数:14,代码来源:LuBottomMenu.java

示例11: onComplete

import java.util.ArrayDeque; //导入方法依赖的package包/类
@Override
public void onComplete() {
    final ArrayDeque<UnicastSubject<T>> ws = windows;
    while (!ws.isEmpty()) {
        ws.poll().onComplete();
    }
    actual.onComplete();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:9,代码来源:ObservableWindow.java

示例12: floodFillTarget

import java.util.ArrayDeque; //导入方法依赖的package包/类
public int floodFillTarget(TileFlags source, TileFlags destination, int x, int y) {
    int cnt = 0;
    ArrayDeque<int[]> stack = new ArrayDeque<>();
    stack.push(new int[]{x, y});

    while (!stack.isEmpty()) {
        int[] nxt = stack.pop();
        x = nxt[0];
        y = nxt[1];
        if (source.getFlag(x, y)) { // Set in src
            source.setFlag(x, y, false); // Clear source
            destination.setFlag(x, y, true); // Set in destination
            cnt++;
            if (source.getFlag(x + 1, y)) {
                stack.push(new int[]{x + 1, y});
            }
            if (source.getFlag(x - 1, y)) {
                stack.push(new int[]{x - 1, y});
            }
            if (source.getFlag(x, y + 1)) {
                stack.push(new int[]{x, y + 1});
            }
            if (source.getFlag(x, y - 1)) {
                stack.push(new int[]{x, y - 1});
            }
        }
    }
    return cnt;
}
 
开发者ID:DRE2N,项目名称:FactionsXL,代码行数:30,代码来源:EngineDynmap.java

示例13: testClone

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * A cloned deque has same elements in same order
 */
public void testClone() throws Exception {
    ArrayDeque<Integer> x = populatedDeque(SIZE);
    ArrayDeque<Integer> y = x.clone();

    assertNotSame(y, x);
    assertEquals(x.size(), y.size());
    assertEquals(x.toString(), y.toString());
    assertTrue(Arrays.equals(x.toArray(), y.toArray()));
    while (!x.isEmpty()) {
        assertFalse(y.isEmpty());
        assertEquals(x.remove(), y.remove());
    }
    assertTrue(y.isEmpty());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:ArrayDequeTest.java

示例14: propagateRemove

import java.util.ArrayDeque; //导入方法依赖的package包/类
private static void propagateRemove(ArrayDeque<LightNode> removeQueue, ArrayDeque<LightNode> addQueue,
		LightWorldSection w) {
	if (removeQueue.isEmpty())
		return;

	while (!removeQueue.isEmpty()) {
		LightNode n = removeQueue.pop();
		int x = n.x;
		int y = n.y;
		int z = n.z;
		int l = n.l;

		if (l <= 1)
			continue;

		tryPropagateRemove(removeQueue, addQueue, w, x - 1, y, z, l);
		tryPropagateRemove(removeQueue, addQueue, w, x + 1, y, z, l);
		tryPropagateRemove(removeQueue, addQueue, w, x, y, z - 1, l);
		tryPropagateRemove(removeQueue, addQueue, w, x, y, z + 1, l);
		if (y > 0)
			tryPropagateRemove(removeQueue, addQueue, w, x, y - 1, z, 16); // 16
																			// is
																			// higher
																			// than
																			// maximum
																			// light,
																			// therefore
																			// the
																			// sunlight
																			// is
																			// always
																			// removed
		tryPropagateRemove(removeQueue, addQueue, w, x, y + 1, z, l);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:36,代码来源:SunLight.java

示例15: randomTick

import java.util.ArrayDeque; //导入方法依赖的package包/类
@Override
public int randomTick(World world, Area area, final int blockX, final int blockY, final int blockZ, int meta) {
	if (meta == 1) {
		HashSet<BlockReference> checked = new HashSet<BlockReference>();
		ArrayDeque<BlockReference> todo = new ArrayDeque<BlockReference>();
		BlockReference start = new BlockReference().setFromBlockCoordinates(blockX, blockY, blockZ);
		todo.add(start.copy().offset(-1, 0, 0));
		todo.add(start.copy().offset(1, 0, 0));
		todo.add(start.copy().offset(0, -1, 0));
		todo.add(start.copy().offset(0, 1, 0));
		todo.add(start.copy().offset(0, 0, -1));
		todo.add(start.copy().offset(0, 0, 1));
		while (!todo.isEmpty()) {
			BlockReference poll = todo.poll();
			int x = poll.blockX;
			int y = poll.blockY;
			int z = poll.blockZ;
			Area a = area;

			randomTickMeta(x, z, a, area, meta);

			if (y < 0 || y > a.maxY) {
				continue;
			}
			Block b = a.getBlock(x, y, z);
			if (b == Blocks.leaves) {
				add(checked, todo, start, poll, -1, 0, 0);
				add(checked, todo, start, poll, 1, 0, 0);
				add(checked, todo, start, poll, 0, -1, 0);
				add(checked, todo, start, poll, 0, 1, 0);
				add(checked, todo, start, poll, 0, 0, -1);
				add(checked, todo, start, poll, 0, 0, 1);
			} else if (b == Blocks.log) {
				return meta;
			}
		}
		area.setBlock(null, blockX, blockY, blockZ, 0);
		dropItems(Cubes.getServer().world, blockX + area.minBlockX, blockY, blockZ + area.minBlockZ, meta);
	}
	return meta;
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:42,代码来源:BlockLeaves.java


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