本文整理汇总了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));
}
示例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);
}
}
示例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();
}
示例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);
}
}
}
}
示例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();
}
示例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;
}
示例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);
}
示例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);
}
}
}
}
}
示例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);
}
}
示例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);
}
示例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));
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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) {}
}