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


Java ArrayDeque.pop方法代码示例

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


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

示例1: search

import java.util.ArrayDeque; //导入方法依赖的package包/类
public static int search(byte[] target, byte[] input) {
    Object[] targetB = new Byte[target.length];
    int x = 0;
    while (x < target.length) {
        targetB[x] = target[x];
        ++x;
    }
    int idx = -1;
    ArrayDeque<Byte> q = new ArrayDeque<Byte>(input.length);
    int i = 0;
    while (i < input.length) {
        if (q.size() == targetB.length) {
            Object[] cur = q.toArray(new Byte[0]);
            if (Arrays.equals(cur, targetB)) {
                idx = i - targetB.length;
                break;
            }
            q.pop();
            q.addLast(input[i]);
        } else {
            q.addLast(input[i]);
        }
        ++i;
    }
    return idx;
}
 
开发者ID:thane98,项目名称:3DSFE-Randomizer,代码行数:27,代码来源:BinUtils.java

示例2: 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 - 1);
		tryPropagateAdd(lightQueue, w, x + 1, y, z, l - 1);
		tryPropagateAdd(lightQueue, w, x, y, z - 1, l - 1);
		tryPropagateAdd(lightQueue, w, x, y, z + 1, l - 1);
		if (y > 0)
			tryPropagateAdd(lightQueue, w, x, y - 1, z, l); // go down
															// without loss
															// in strength
		tryPropagateAdd(lightQueue, w, x, y + 1, z, l - 1);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:26,代码来源:SunLight.java

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

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

示例5: 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 - 1);
    tryPropagateAdd(lightQueue, w, x + 1, y, z, l - 1);
    tryPropagateAdd(lightQueue, w, x, y, z - 1, l - 1);
    tryPropagateAdd(lightQueue, w, x, y, z + 1, l - 1);
    if (y > 0) tryPropagateAdd(lightQueue, w, x, y - 1, z, l); // go down without loss in strength
    tryPropagateAdd(lightQueue, w, x, y + 1, z, l - 1);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:21,代码来源:SunLight.java

示例6: 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,代码行数:22,代码来源:SunLight.java

示例7: 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,代码行数:21,代码来源:BlockLight.java

示例8: 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,代码行数:21,代码来源:BlockLight.java

示例9: findCallSite

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * Locate a late inline call site: find, in this instance's
 * {@linkplain #calls call sites}, the one furthest down the given call
 * stack.
 *
 * Multiple chains of identical call sites with the same method name / bci
 * combination are possible, so we have to try them all until we find the
 * late inline call site that has a matching inline ID.
 *
 * @return a matching call site, or {@code null} if none was found.
 */
public CallSite findCallSite(ArrayDeque<CallSite> sites) {
    if (calls == null) {
        return null;
    }
    CallSite site = sites.pop();
    for (CallSite c : calls) {
        if (c.matches(site)) {
            if (!sites.isEmpty()) {
                CallSite res = c.findCallSite(sites);
                if (res != null) {
                    sites.push(site);
                    return res;
                }
            } else {
                sites.push(site);
                return c;
            }
        }
    }
    sites.push(site);
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:CallSite.java

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

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

示例12: extendClassWhile

import java.util.ArrayDeque; //导入方法依赖的package包/类
private void extendClassWhile(ArrayDeque<Class> toCheck, LuaTable delegations) {
	while (!toCheck.isEmpty()) {
		Class check = toCheck.pop();
		for (Method method : check.getDeclaredMethods()) {
			if (Modifier.isAbstract(method.getModifiers())) {
				if (delegations.get(method.getName()).isnil())
					throw new DynamicDelegationError("No delegation for abstract method " + method);
			}
		}
		check = check.getSuperclass();
		if (check != null && check != Object.class)
			toCheck.add(check);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:15,代码来源:LuaGeneration.java

示例13: testPop

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * pop() removes next element, or throws NSEE if empty
 */
public void testPop() {
    ArrayDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.pop());
    }
    try {
        q.pop();
        shouldThrow();
    } catch (NoSuchElementException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ArrayDequeTest.java

示例14: buildTree

import java.util.ArrayDeque; //导入方法依赖的package包/类
public Node buildTree() {
	// sort the triples before adding them
	//this.sortTriples();    	
	
	PriorityQueue<Node> nodesQueue = getNodesQueue();
	
	Node tree = nodesQueue.poll();
	
	// set the root node with the variables that need to be projected
	ArrayList<String> projectionList = new ArrayList<String>();
	for(int i = 0; i < variables.size(); i++)
		projectionList.add(variables.get(i).getVarName());
	tree.setProjectionList(projectionList);
	
	// visit the hypergraph to build the tree
	Node currentNode = tree;
	ArrayDeque<Node> visitableNodes = new ArrayDeque<Node>();
	while(!nodesQueue.isEmpty()){
		
		int limitWidth = 0;
		// if a limit not set, a heuristic decides the width 
		if(treeWidth == -1){
	    	treeWidth = heuristicWidth(currentNode); 
		}
		
		Node newNode =  findRelateNode(currentNode, nodesQueue);
		
		// there are nodes that are impossible to join with the current tree width
		if (newNode == null && visitableNodes.isEmpty()) {
			// set the limit to infinite and execute again
			treeWidth = Integer.MAX_VALUE;
			return buildTree();
		}
		
		// add every possible children (wide tree) or limit to a custom width
		// stop if a width limit exists and is reached
		while(newNode != null && !(treeWidth > 0 && limitWidth == treeWidth)){
			
			// append it to the current node and to the queue
			currentNode.addChildren(newNode);
			
			// visit again the new child
			visitableNodes.add(newNode);
			
			// remove consumed node and look for another one
			nodesQueue.remove(newNode);
			newNode = findRelateNode(currentNode, nodesQueue);
			
			limitWidth++;
		}
		
		// next Node is one of the children
		if(!visitableNodes.isEmpty() && !nodesQueue.isEmpty()){
			currentNode = visitableNodes.pop();
			
		}
	}
	
	return tree;
}
 
开发者ID:tf-dbis-uni-freiburg,项目名称:PRoST,代码行数:61,代码来源:Translator.java

示例15: extendClass

import java.util.ArrayDeque; //导入方法依赖的package包/类
public static Class extendClass(Class<?> extend, final LuaTable delegations, Class<?>... inherit) {
  long startTime = System.nanoTime();

  ArrayDeque<Class> toCheck = new ArrayDeque<Class>();
  toCheck.add(extend);
  toCheck.addAll(Arrays.asList(inherit));
  while (!toCheck.isEmpty()) {
    Class check = toCheck.pop();
    for (Method method : check.getDeclaredMethods()) {
      if (Modifier.isAbstract(method.getModifiers())) {
        if (delegations.get(method.getName()).isnil())
          throw new DynamicDelegationError("No delegation for abstract method " + method);
      }
    }
    check = check.getSuperclass();
    if (check != null && check != Object.class) toCheck.add(check);
  }
  
  try {
    ReceiverTypeDefinition<?> build = b.subclass(extend).implement(inherit)
            .method(not(isConstructor()).and(isAbstract())).intercept(MethodDelegation.to(new AbstractInterceptor(delegations)));
    if (!delegations.get("__new__").isnil()) {
      build = build.constructor(isConstructor()).intercept(SuperMethodCall.INSTANCE.andThen(MethodDelegation.to(new ConstructorInterceptor(delegations))));
    }
    Junction<MethodDescription> publicMethods = not(isConstructor().or(isAbstract())).and(isPublic()).and(new ElementMatcher<MethodDescription>() {
      @Override
      public boolean matches(MethodDescription target) {
        return !delegations.get(target.getName()).isnil();
      }
    });
    build = build.method(publicMethods).intercept(MethodDelegation.to(new PublicInterceptor(delegations)));
    
    Unloaded unloaded = build.make();
    Loaded loaded = Compatibility.get().load(unloaded);
    Class c = loaded.getLoaded();
    Log.debug("Created dynamic class " + c.getName() + " in " + ((System.nanoTime() - startTime) / 1000000) + "ms");
    return c;
  } catch (Exception e) {
    Log.error("Failed to create dynamic class " + extend.getName() + " " + Arrays.toString(inherit));
    throw new CubesException("Failed to make dynamic class", e);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:43,代码来源:LuaGeneration.java


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