當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。