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


Java ArrayDeque.add方法代码示例

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


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

示例1: trackNewWorkUnit

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * Store dependency tables for later retrieval by the EE.
 * @param workunit
 */
void trackNewWorkUnit(final Map<Integer, List<VoltTable>> dependencies) {
    for (final Entry<Integer, List<VoltTable>> e : dependencies.entrySet()) {
        // could do this optionally - debug only.
        if (debug.val) verifyDependencySanity(e.getKey(), e.getValue());
        // create a new list of references to the workunit's table
        // to avoid any changes to the WorkUnit's list. But do not
        // copy the table data.
        ArrayDeque<VoltTable> deque = m_depsById.get(e.getKey());
        if (deque == null) {
            deque = new ArrayDeque<VoltTable>();
        // intentionally overwrite the previous dependency id.
        // would a lookup and a clear() be faster?
        m_depsById.put(e.getKey(), deque);
        } else {
            deque.clear();
        }
        for (VoltTable vt : e.getValue()) {
            if (vt != null) deque.add(vt);
        } // FOR
    }
    if (debug.val) LOG.debug("Current InputDepencies:\n" + StringUtil.formatMaps(m_depsById));
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:27,代码来源:ExecutionEngine.java

示例2: addSunlight

import java.util.ArrayDeque; //导入方法依赖的package包/类
public static void addSunlight(int x, int y, int z, Area area, LightWorldSection w) {
  if (y > 0 && y <= area.maxY) {
    ArrayDeque<LightNode> lightQueue = new ArrayDeque<LightNode>(1000);

    if (y <= w.maxY(x + 1, z) && w.transparent(x + 1, y, z))
      lightQueue.add(new LightNode(x + 1, y, z, w.getSunlight(x + 1, y, z)));
    if (y <= w.maxY(x - 1, z) && w.transparent(x - 1, y, z))
      lightQueue.add(new LightNode(x - 1, y, z, w.getSunlight(x - 1, y, z)));
    if (y < w.maxY(x, z) && w.transparent(x, y + 1, z))
      lightQueue.add(new LightNode(x, y + 1, z, w.getSunlight(x, y + 1, z)));
    if (y > 0 && w.transparent(x, y - 1, z)) lightQueue.add(new LightNode(x, y - 1, z, w.getSunlight(x, y - 1, z)));
    if (y <= w.maxY(x, z + 1) && w.transparent(x, y, z + 1))
      lightQueue.add(new LightNode(x, y, z + 1, w.getSunlight(x, y, z + 1)));
    if (y <= w.maxY(x, z - 1) && w.transparent(x, y, z - 1))
      lightQueue.add(new LightNode(x, y, z - 1, w.getSunlight(x, y, z - 1)));

    propagateAdd(lightQueue, w);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:20,代码来源:SunLight.java

示例3: initialSunlight

import java.util.ArrayDeque; //导入方法依赖的package包/类
public static void initialSunlight(Area area) {
	initalSunlight.lock(); // used to prevent all the World Generation
							// threads grabbing different areas and
							// deadlocking
	LightWorldSection worldSection = new LightWorldSection(area);
	initalSunlight.unlock();

	ArrayDeque<LightNode> lightQueue = new ArrayDeque<>();
	int max = 15;
	for (int x = 0; x < SIZE_BLOCKS; x++) {
		for (int z = 0; z < SIZE_BLOCKS; z++) {
			int hmRef = getHeightMapRef(x, z);
			int h = area.heightmap[hmRef] + 1;

			int ref = getRef(x, h, z);
			for (int y = 0; y <= (area.maxY - h); y++) {
				int r = ref + (y * MAX_Y_OFFSET);
				area.light[r] = (byte) ((area.light[r] & 0xF) | (max << 4));
			}

			lightQueue.add(new LightNode(x + area.minBlockX, h, z + area.minBlockZ, max));
		}
	}
	propagateAdd(lightQueue, worldSection);
	worldSection.unlock();
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:27,代码来源:SunLight.java

示例4: 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:MohamedSondo,项目名称:ACE_HackerRank,代码行数:18,代码来源:Solution.java

示例5: initialSunlight

import java.util.ArrayDeque; //导入方法依赖的package包/类
public static void initialSunlight(Area area) {
  initalSunlight.lock(); // used to prevent all the World Generation threads grabbing different areas and deadlocking
  LightWorldSection worldSection = new LightWorldSection(area);
  initalSunlight.unlock();

  ArrayDeque<LightNode> lightQueue = new ArrayDeque<>();
  int max = 15;
  for (int x = 0; x < SIZE_BLOCKS; x++) {
    for (int z = 0; z < SIZE_BLOCKS; z++) {
      int hmRef = getHeightMapRef(x, z);
      int h = area.heightmap[hmRef] + 1;

      int ref = getRef(x, h, z);
      for (int y = 0; y <= (area.maxY - h); y++) {
        int r = ref + (y * MAX_Y_OFFSET);
        area.light[r] = (byte) ((area.light[r] & 0xF) | (max << 4));
      }

      lightQueue.add(new LightNode(x + area.minBlockX, h, z + area.minBlockZ, max));
    }
  }
  propagateAdd(lightQueue, worldSection);
  worldSection.unlock();
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:25,代码来源:SunLight.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: add

import java.util.ArrayDeque; //导入方法依赖的package包/类
private void add(HashSet<BlockReference> checked, ArrayDeque<BlockReference> todo, BlockReference start, BlockReference b, int x, int y, int z) {
  b = b.copy().offset(x, y, z);
  int dX = start.blockX - b.blockX;
  int dY = start.blockY - b.blockY;
  int dZ = start.blockZ - b.blockZ;
  int distance2 = dX * dX + dY * dY + dZ * dZ;
  if (distance2 <= 16 && checked.add(b)) todo.add(b);
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:9,代码来源:BlockLeaves.java

示例8: stop

import java.util.ArrayDeque; //导入方法依赖的package包/类
public static void stop(String tag) {
  if (!enabled.get()) return;
  ThreadPerformance threadPerformance = threadNode.get();
  synchronized (threadPerformance) {
    PerformanceNode last = threadPerformance.active.getLast();
    if (last.tag.equals(tag) && !(last instanceof ThreadPerformance)) {
      last.end = System.nanoTime() - startTime;
      threadPerformance.active.remove(last);
    } else {
      Log.error("Performance: stopping tag '" + tag + "' when the last tag is '" + last.tag + "'");
      PerformanceNode node = null;
      for (PerformanceNode performanceNode : threadPerformance.active) {
        if (performanceNode.tag.equals(tag)) {
          node = performanceNode;
          break;
        }
      }
      if (node == null) {
        Log.error("Performance: tag '" + tag + "' was never started");
        return;
      }
      ArrayDeque<PerformanceNode> d = new ArrayDeque<PerformanceNode>();
      d.add(node);
      while (d.size() > 0) {
        PerformanceNode n = d.getFirst();
        if (n.end == 0) {
          n.end = System.nanoTime() - startTime;
          threadPerformance.active.remove(n);
          d.addAll(n.children);
        }
      }
    }
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:35,代码来源:Performance.java

示例9: addLight

import java.util.ArrayDeque; //导入方法依赖的package包/类
public static void addLight(int x, int y, int z, int l, Area area, LightWorldSection lws) {
  if (y > 0 && y <= area.maxY) {
    ArrayDeque<LightNode> lightQueue = new ArrayDeque<LightNode>(1000);

    area.setLight(x - area.minBlockX, y, z - area.minBlockZ, l);
    lightQueue.add(new LightNode(x, y, z, l));
    propagateAdd(lightQueue, lws);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:10,代码来源:BlockLight.java

示例10: addDependency

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * Add a single dependency. Exists only for test cases.
 * @param depId
 * @param vt
 */
void addDependency(final int depId, final VoltTable vt) {
    ArrayDeque<VoltTable> deque = m_depsById.get(depId);
    if (deque == null) {
        deque = new ArrayDeque<VoltTable>();
        m_depsById.put(depId, deque);
    }
    deque.add(vt);
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:14,代码来源:ExecutionEngine.java

示例11: testSize

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * size changes when elements added and removed
 */
public void testSize() {
    ArrayDeque q = populatedDeque(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(SIZE - i, q.size());
        q.removeFirst();
    }
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.size());
        q.add(new Integer(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ArrayDequeTest.java

示例12: removeSunlight

import java.util.ArrayDeque; //导入方法依赖的package包/类
public static void removeSunlight(int x, int y, int z, Area area, LightWorldSection lws) {
  if (y > 0 && y <= area.maxY) {
    ArrayDeque<LightNode> removeQueue = new ArrayDeque<LightNode>(1000);
    ArrayDeque<LightNode> addQueue = new ArrayDeque<LightNode>(1000);

    int prev = area.getSunlight(x - area.minBlockX, y, z - area.minBlockZ);
    area.setSunlight(x - area.minBlockX, y, z - area.minBlockZ, 0);
    removeQueue.add(new LightNode(x, y, z, prev));
    propagateRemove(removeQueue, addQueue, lws);
    propagateAdd(addQueue, lws);
  }
}
 
开发者ID:RedTroop,项目名称:Cubes,代码行数:13,代码来源:SunLight.java

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

示例14: removeSunlight

import java.util.ArrayDeque; //导入方法依赖的package包/类
public static void removeSunlight(int x, int y, int z, Area area, LightWorldSection lws) {
	if (y > 0 && y <= area.maxY) {
		ArrayDeque<LightNode> removeQueue = new ArrayDeque<LightNode>(1000);
		ArrayDeque<LightNode> addQueue = new ArrayDeque<LightNode>(1000);

		int prev = area.getSunlight(x - area.minBlockX, y, z - area.minBlockZ);
		area.setSunlight(x - area.minBlockX, y, z - area.minBlockZ, 0);
		removeQueue.add(new LightNode(x, y, z, prev));
		propagateRemove(removeQueue, addQueue, lws);
		propagateAdd(addQueue, lws);
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:13,代码来源:SunLight.java

示例15: testToArray_NullArg

import java.util.ArrayDeque; //导入方法依赖的package包/类
/**
 * toArray(null) throws NullPointerException
 */
public void testToArray_NullArg() {
    ArrayDeque l = new ArrayDeque();
    l.add(new Object());
    try {
        l.toArray(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:ArrayDequeTest.java


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