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


Java ArrayDeque类代码示例

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


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

示例1: tryPropagateRemove

import java.util.ArrayDeque; //导入依赖的package包/类
private static void tryPropagateRemove(ArrayDeque<LightNode> removeQueue, ArrayDeque<LightNode> addQueue,
		LightWorldSection w, int x, int y, int z, int l) {
	int dX = CoordinateConverter.area(x) - w.initialAreaX;
	int dZ = CoordinateConverter.area(z) - w.initialAreaZ;
	Area a = w.areas[dX + 1][dZ + 1];
	int ref = getRef(x - a.minBlockX, y, z - a.minBlockZ);
	if (!a.isReady() || y > a.maxY || !TransparencyManager.isTransparent(a.blocks[ref]))
		return;
	int p = ((a.light[ref] >> 4) & 0xF);
	if (p != 0 && p < l) {
		a.light[ref] = (byte) (a.light[ref] & 0xF); // same as
													// ((a.light[ref] &
													// 0xF0) | (0 << 4))
		a.updateRender(y / SIZE_BLOCKS);
		a.modify();
		removeQueue.add(new LightNode(x, y, z, p));
	} else if (p >= l) {
		addQueue.add(new LightNode(x, y, z, p));
	}
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:21,代码来源:SunLight.java

示例2: testSpliterator_characteristics

import java.util.ArrayDeque; //导入依赖的package包/类
/**
 * Spliterator characteristics are as advertised
 */
public void testSpliterator_characteristics() {
    ArrayDeque q = new ArrayDeque();
    Spliterator s = q.spliterator();
    int characteristics = s.characteristics();
    int required = Spliterator.NONNULL
        | Spliterator.ORDERED
        | Spliterator.SIZED
        | Spliterator.SUBSIZED;
    assertEquals(required, characteristics & required);
    assertTrue(s.hasCharacteristics(required));
    assertEquals(0, characteristics
                 & (Spliterator.CONCURRENT
                    | Spliterator.DISTINCT
                    | Spliterator.IMMUTABLE
                    | Spliterator.SORTED));
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:ArrayDeque8Test.java

示例3: walkTypeHierarchy

import java.util.ArrayDeque; //导入依赖的package包/类
/**
 * Visits all types in a type hierarchy in breadth-first order, super-classes first and then implemented interfaces.
 *
 * @param clazz the type of whose type hierarchy to visit.
 * @param excludedTypes the types not to walk when encountered in the hierarchy.
 * @param visitor the visitor to call for each type in the hierarchy.
 */
public static <T> void walkTypeHierarchy(Class<T> clazz, Collection<Class<?>> excludedTypes, TypeVisitor<? extends T> visitor) {
    Set<Class<?>> seenInterfaces = Sets.newHashSet();
    Queue<Class<? super T>> queue = new ArrayDeque<Class<? super T>>();
    queue.add(clazz);
    Class<? super T> type;
    while ((type = queue.poll()) != null) {
        if (excludedTypes.contains(type)) {
            continue;
        }

        visitor.visitType(type);

        Class<? super T> superclass = type.getSuperclass();
        if (superclass != null) {
            queue.add(superclass);
        }
        for (Class<?> iface : type.getInterfaces()) {
            if (seenInterfaces.add(iface)) {
                queue.add(Cast.<Class<? super T>>uncheckedCast(iface));
            }
        }
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:31,代码来源:Types.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:rshaghoulian,项目名称:HackerRank_solutions,代码行数:18,代码来源:Solution.java

示例5: postCompleteCancelled

import java.util.ArrayDeque; //导入依赖的package包/类
@Test
public void postCompleteCancelled() {
    final TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
    ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
    AtomicLong state = new AtomicLong();
    BooleanSupplier isCancelled = new BooleanSupplier() {
        @Override
        public boolean getAsBoolean() throws Exception {
            return ts.isCancelled();
        }
    };

    ts.onSubscribe(new BooleanSubscription());
    queue.offer(1);
    state.getAndIncrement();
    ts.cancel();

    QueueDrainHelper.postComplete(ts, queue, state, isCancelled);

    ts.assertEmpty();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:22,代码来源:QueueDrainHelperTest.java

示例6: postCompleteEmpty

import java.util.ArrayDeque; //导入依赖的package包/类
@Test
public void postCompleteEmpty() {
    TestSubscriber<Integer> ts = new TestSubscriber<Integer>();
    ArrayDeque<Integer> queue = new ArrayDeque<Integer>();
    AtomicLong state = new AtomicLong();
    BooleanSupplier isCancelled = new BooleanSupplier() {
        @Override
        public boolean getAsBoolean() throws Exception {
            return false;
        }
    };

    ts.onSubscribe(new BooleanSubscription());

    QueueDrainHelper.postComplete(ts, queue, state, isCancelled);

    ts.assertResult();
}
 
开发者ID:akarnokd,项目名称:RxJava3-preview,代码行数:19,代码来源:QueueDrainHelperTest.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_2,代码行数:24,代码来源:BlockLight.java

示例8: testRemoveElement

import java.util.ArrayDeque; //导入依赖的package包/类
/**
 * remove(x) removes x and returns true if present
 */
public void testRemoveElement() {
    ArrayDeque q = populatedDeque(SIZE);
    for (int i = 1; i < SIZE; i += 2) {
        assertTrue(q.contains(i));
        assertTrue(q.remove(i));
        assertFalse(q.contains(i));
        assertTrue(q.contains(i - 1));
    }
    for (int i = 0; i < SIZE; i += 2) {
        assertTrue(q.contains(i));
        assertTrue(q.remove(i));
        assertFalse(q.contains(i));
        assertFalse(q.remove(i + 1));
        assertFalse(q.contains(i + 1));
    }
    assertTrue(q.isEmpty());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:ArrayDequeTest.java

示例9: toStyleProcessorOverThreshold

import java.util.ArrayDeque; //导入依赖的package包/类
@Test
public void toStyleProcessorOverThreshold() {
	final Deque<Object> contextData = new ArrayDeque<>();
	contextData.add(1); // Index
	final SlaData data = new SlaData();
	data.setDuration(13L); // Duration;
	contextData.add(data);
	final JiraSlaComputations slaComputations = new JiraSlaComputations();
	final SlaConfiguration slaConfiguration0 = new SlaConfiguration();
	slaConfiguration0.setThreshold(14);
	final SlaConfiguration slaConfiguration1 = new SlaConfiguration();
	slaConfiguration1.setThreshold(12);
	slaComputations.setSlaConfigurations(Arrays.asList(slaConfiguration0, slaConfiguration1));
	Assert.assertEquals("invalid", resource.toStyleProcessor(slaComputations, "normal", "invalid").getValue(contextData));

}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:17,代码来源:JiraExportPluginResourceTest.java

示例10: findAncestor

import java.util.ArrayDeque; //导入依赖的package包/类
/**
 * Traverse ancestors of the given type, in the same order as {@link #ancestors(Class, boolean)},
 * and return the first ancestor for which the given predicate returns true.
 */
public static @Nullable <U> Class<? extends U> findAncestor(Class<? extends U> type, Class<U> upperBound, java.util.function.Predicate<Class<?>> pred) {
    Deque<Class<? extends U>> queue = new ArrayDeque<>();
    queue.add(type);
    while(!queue.isEmpty()) {
        final Class<? extends U> t = queue.remove();
        if(pred.test(t)) return t;

        if(t.getSuperclass() != null && upperBound.isAssignableFrom(t.getSuperclass())) {
            queue.add((Class<? extends U>) t.getSuperclass());
        }

        for(Class<?> iface : t.getInterfaces()) {
            if(upperBound.isAssignableFrom(iface)) {
                queue.add((Class<? extends U>) iface);
            }
        }
    }
    return null;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:24,代码来源:Types.java

示例11: NodeWorkList

import java.util.ArrayDeque; //导入依赖的package包/类
public NodeWorkList(Graph graph, boolean fill, int iterationLimitPerNode) {
    visited = graph.createNodeBitMap();
    inQueue = graph.createNodeBitMap();
    if (fill) {
        ArrayDeque<Node> deque = new ArrayDeque<>(graph.getNodeCount());
        for (Node node : graph.getNodes()) {
            deque.add(node);
        }
        worklist = deque;
    } else {
        worklist = new ArrayDeque<>();
    }
    if (iterationLimitPerNode > 0) {
        iterationLimit = iterationLimitPerNode * graph.getNodeCount();
    }
}
 
开发者ID:arodchen,项目名称:MaxSim,代码行数:17,代码来源:NodeWorkList.java

示例12: DefUseVisitor

import java.util.ArrayDeque; //导入依赖的package包/类
public DefUseVisitor(int iter, JavaClass[] classInfos, 
		DataDependenceGraph ddg, Map<ParserRuleContext, Object> pdNodes) {
	Logger.log("FILE IS: " + currentFile);
	this.ddg = ddg;
	changed = false;
	iteration = iter;
	analysisVisit = false;
	this.pdNodes = pdNodes;
	this.classInfos = classInfos;
	defList = new LinkedHashSet<>();
	useList = new LinkedHashSet<>();
	selfFlowList = new LinkedHashSet<>();
	activeClasses = new ArrayDeque<>();
	methodDefInfo = null;
	methodParams = new JavaField[0];
	localVars = new ArrayList<>();
}
 
开发者ID:ghaffarian,项目名称:progex,代码行数:18,代码来源:JavaDDGBuilder.java

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

示例14: parse

import java.util.ArrayDeque; //导入依赖的package包/类
public SyntaxTree parse( final List<Token> tokens ) {
	checkNotNull( tokens, "Null tokens list." );
	final Queue<Token> outputQueue = new LinkedList<Token>();
	final Deque<Token> operationStack = new ArrayDeque<>();
	for ( final Token token : tokens ) {
		if ( token.getType().isLiteral() ) {
			outputQueue.offer( token );
			continue;
		}
		if ( token.getType().isOperation() ) {
			processOperationToken( outputQueue, operationStack, token );
			continue;
		}
		if ( token.getType().isGrouper() ) {
			processGrouperTypeToken( outputQueue, operationStack, token );
		}
	}
	validateParenthesesMatching( operationStack );
	pushRemainingOperatorToOutput( outputQueue, operationStack );
	return SyntaxTree.create( outputQueue );
}
 
开发者ID:WellCosta,项目名称:MathMax,代码行数:22,代码来源:Parser.java

示例15: spreadLight

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

		lightIf1(x, y, z, w, lightQueue);

		lightIf2(x, y, z, w, lightQueue);

		if (y <= w.maxY(x, z + 1) && (w.transparent(x, y, z + 1) || w.isLightSource(x, y, z + 1)))
			lightQueue.add(new LightNode(x, y, z + 1, w.getLight(x, y, z + 1)));
		if (y <= w.maxY(x, z - 1) && (w.transparent(x, y, z - 1) || w.isLightSource(x, y, z - 1)))
			lightQueue.add(new LightNode(x, y, z - 1, w.getLight(x, y, z - 1)));

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


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