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


Java Stack.addAll方法代码示例

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


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

示例1: visit

import java.util.Stack; //导入方法依赖的package包/类
@Override
public boolean visit(DependencyNode node) {
    if (root == null) {
        root = node;
        directs = new HashSet<DependencyNode>();
        path = new Stack<DependencyNode>();
        allPaths = new HashSet<Stack<DependencyNode>>();
        return true;
    }
    path.push(node);
    Artifact artifact = node.getArtifact();
    if (key.equals(artifact.getDependencyConflictId())) {
        if (!path.isEmpty()) {
            directs.add(path.firstElement());
            Stack<DependencyNode> copy = new Stack<DependencyNode>();
            copy.addAll(path);
            allPaths.add(copy);
        }
        return false;
    }
    return true;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:23,代码来源:DependencyExcludeNodeVisitor.java

示例2: getQuantiles

import java.util.Stack; //导入方法依赖的package包/类
public static Map<String, Long> getQuantiles(Long[] rtimes, long average) {
    Map<String, Long> result = new HashMap<>();
    Arrays.sort(rtimes);

    double[] quantiles = {0.0, 0.90, 0.95, 0.99, 1.00};

    Stack<Long> timings = new Stack<>();
    timings.addAll(Arrays.asList(rtimes));
    double level = 1.0;
    Long timing = 0L;
    long sqr_diffs = 0;
    for (int qn = quantiles.length - 1; qn >= 0; qn--) {
        double quan = quantiles[qn];
        while (level >= quan && !timings.empty()) {
            timing = timings.pop();
            level -= 1.0 / rtimes.length;
            sqr_diffs += timing * Math.pow(timing - average, 2);
        }
        result.put(getMetricLabel(quan), timing);
    }
    result.put("std", (long) Math.sqrt(sqr_diffs / rtimes.length));
    return result;
}
 
开发者ID:Blazemeter,项目名称:jmeter-bzm-plugins,代码行数:24,代码来源:JSONConverter.java

示例3: expansionDFS

import java.util.Stack; //导入方法依赖的package包/类
public ArrayList<Coordinate> expansionDFS(Grid gameboard, TerrainType terrain, Settlement settlement){
    ArrayList<Coordinate> hexesEncountered = settlement.getSettlementCoordinates();
    ArrayList<Coordinate> newHexesAdded = new ArrayList<>();
    Stack<Coordinate> coords = new Stack();
    coords.addAll(hexesEncountered);

    while(!coords.empty()){
        Coordinate currentAdjacentCoordinate = coords.pop();
        ArrayList<Coordinate> neighboringCoordinates = findAdjacentCoords(gameboard, terrain, currentAdjacentCoordinate);
        for(int i=0; i<neighboringCoordinates.size(); i++){
            if(SettlementExpansionRules.contains(hexesEncountered, neighboringCoordinates.get(i))== false){
                newHexesAdded.add(neighboringCoordinates.get(i));
                hexesEncountered.add(neighboringCoordinates.get(i));
                coords.push(neighboringCoordinates.get(i));
            }
        }
    }
    return newHexesAdded;
}
 
开发者ID:jlhbaseball15,项目名称:TigerIsland,代码行数:20,代码来源:GameState.java

示例4: expansionDFS

import java.util.Stack; //导入方法依赖的package包/类
public ArrayList<Coordinate> expansionDFS(Grid gameboard, TerrainType terrain, Settlement settlement){
    ArrayList<Coordinate> hexesEncountered = settlement.getSettlementCoordinates();
    ArrayList<Coordinate> newHexesAdded = new ArrayList<>();
    Stack<Coordinate> coords = new Stack();
    coords.addAll(hexesEncountered);

    while(!coords.empty()){
        Coordinate currentAdjacentCoordinate = coords.pop();
        ArrayList<Coordinate> neighboringCoordinates = findAdjacentCoords(gameboard, terrain, currentAdjacentCoordinate);
        for(int i=0; i<neighboringCoordinates.size(); i++){
            if(contains(hexesEncountered, neighboringCoordinates.get(i))== false){
                newHexesAdded.add(neighboringCoordinates.get(i));
                hexesEncountered.add(neighboringCoordinates.get(i));
                coords.push(neighboringCoordinates.get(i));
            }
        }
    }
    return newHexesAdded;
}
 
开发者ID:jlhbaseball15,项目名称:TigerIsland,代码行数:20,代码来源:SettlementExpansionRules.java

示例5: oneHive

import java.util.Stack; //导入方法依赖的package包/类
public boolean oneHive(Tile toMove) {
	List<Tile> list = getPieceNeighbors(toMove);

	if (toMove.getZ() != 0 || list.isEmpty())
		return true;

	HashSet<Tile> visited = new HashSet<Tile>();
	Stack<Tile> nextTiles = new Stack<Tile>();

	visited.add(toMove);
	nextTiles.add(list.get(0));
	Tile current;
	while (!nextTiles.isEmpty()) {
		if (!visited.contains(current = nextTiles.pop())) {
			nextTiles.addAll(getPieceNeighbors(current));
			visited.add(current);
		}
	}
	return getNbPieceOnTheBoard() == visited.size();
}
 
开发者ID:Plinz,项目名称:Hive_Game,代码行数:21,代码来源:Board.java

示例6: added

import java.util.Stack; //导入方法依赖的package包/类
@Override
synchronized public void added ( final ItemDescriptor descriptor )
{
    if ( this.itemList.containsKey ( descriptor ) )
    {
        return;
    }

    final String[] groupingArray = this.groupProvider.getGrouping ( descriptor );
    if ( groupingArray == null )
    {
        return;
    }

    final Stack<String> pathStack = new Stack<String> ();
    pathStack.addAll ( Arrays.asList ( reverse ( groupingArray ) ) );

    final GroupSubFolder subFolder = this.folder.add ( pathStack, descriptor );

    if ( subFolder != null )
    {
        this.itemList.put ( descriptor, subFolder );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:25,代码来源:GroupFolder.java

示例7: allChildren

import java.util.Stack; //导入方法依赖的package包/类
/**
 * Return all child nodes for the current node (none, if this is a leaf node).
 */
public List<TreebankTreeNode> allChildren() {
    Set<TreebankTreeNode> results = new HashSet<>();
    Stack<TreebankTreeNode> stack = new Stack<>();
    stack.push(this);
    while (!stack.isEmpty()) {
        TreebankTreeNode current = stack.pop();
        if (!results.contains(current)) {
            results.add(current);
            if (current.children.size() == 0) {
                results.add(current);
            }
            stack.addAll(Lists.reverse(current.children));
        }
    }
    return results.stream()
            .sorted(Comparator.comparingInt(t -> t.id))
            .collect(Collectors.toList());
}
 
开发者ID:clearwsd,项目名称:clearwsd,代码行数:22,代码来源:OntoNotesConverter.java

示例8: getFirstRTextAreaDescendant

import java.util.Stack; //导入方法依赖的package包/类
/**
 * Returns the first descendant of a component that is an
 * <code>RTextArea</code>.  This is primarily here to support
 * <code>javax.swing.JLayer</code>s that wrap <code>RTextArea</code>s.
 *
 * @param comp The component to recursively look through.
 * @return The first descendant text area, or <code>null</code> if none
 *         is found.
 */
private static RTextArea getFirstRTextAreaDescendant(Component comp) {
	Stack<Component> stack = new Stack<Component>();
	stack.add(comp);
	while (!stack.isEmpty()) {
		Component current = stack.pop();
		if (current instanceof RTextArea) {
			return (RTextArea)current;
		}
		if (current instanceof Container) {
			Container container = (Container)current;
			stack.addAll(Arrays.asList(container.getComponents()));
		}
	}
	return null;
}
 
开发者ID:Thecarisma,项目名称:powertext,代码行数:25,代码来源:RTextScrollPane.java

示例9: listCases

import java.util.Stack; //导入方法依赖的package包/类
@DataProvider(name="listProvider", parallel=true)
public static Object[][] listCases() {
    final List<Object[]> cases = new LinkedList<>();
    cases.add(new Object[] { Collections.emptyList() });
    cases.add(new Object[] { new ArrayList<>() });
    cases.add(new Object[] { new LinkedList<>() });
    cases.add(new Object[] { new Vector<>() });
    cases.add(new Object[] { new Stack<>() });
    cases.add(new Object[] { new CopyOnWriteArrayList<>() });
    cases.add(new Object[] { Arrays.asList() });

    List<Integer> l = Arrays.asList(42);
    cases.add(new Object[] { new ArrayList<>(l) });
    cases.add(new Object[] { new LinkedList<>(l) });
    cases.add(new Object[] { new Vector<>(l) });
    Stack<Integer> s = new Stack<>(); s.addAll(l);
    cases.add(new Object[]{s});
    cases.add(new Object[] { new CopyOnWriteArrayList<>(l) });
    cases.add(new Object[] { l });
    return cases.toArray(new Object[0][cases.size()]);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:ListDefaults.java

示例10: parse

import java.util.Stack; //导入方法依赖的package包/类
/**
 * Entry point into parsing command line arguments.
 * @param args the command line arguments
 * @return a list with all commands and subcommands initialized by this method
 * @throws ParameterException if the specified command line arguments are invalid
 */
List<CommandLine> parse(String... args) {
    Assert.notNull(args, "argument array");
    if (tracer.isInfo()) {tracer.info("Parsing %d command line args %s%n", args.length, Arrays.toString(args));}
    List<String> expanded = new ArrayList<String>();
    for (String arg : args) { addOrExpand(arg, expanded, new LinkedHashSet<String>()); }
    Stack<String> arguments = new Stack<String>();
    arguments.addAll(reverseList(expanded));
    List<CommandLine> result = new ArrayList<CommandLine>();
    parse(result, arguments, args);
    return result;
}
 
开发者ID:remkop,项目名称:picocli,代码行数:18,代码来源:CommandLine.java

示例11: readCollectionField

import java.util.Stack; //导入方法依赖的package包/类
/**
 * Read data from the given JSONArray and populate the given Collection
 * 
 * @param json_array
 * @param catalog_db
 * @param collection
 * @param inner_classes
 * @throws Exception
 */
@SuppressWarnings("unchecked")
protected static void readCollectionField(final JSONArray json_array, final Database catalog_db, final Collection collection, final Stack<Class<?>> inner_classes) throws Exception {
    // We need to figure out what the inner type of the collection is
    // If it's a Collection or a Map, then we need to instantiate it before
    // we can call readFieldValue() again for it.
    Class<?> inner_class = inner_classes.pop();
    Collection<Class<?>> inner_interfaces = ClassUtil.getInterfaces(inner_class);
    final Stack<Class<?>> next_inner_classes = new Stack<Class<?>>();
    
    for (int i = 0, cnt = json_array.length(); i < cnt; i++) {
        if (i > 0) next_inner_classes.clear();
        next_inner_classes.addAll(inner_classes);
        assert (next_inner_classes.equals(inner_classes));
        Object value = null;

        // Null
        if (json_array.isNull(i)) {
            value = null;
            // Lists
        } else if (inner_interfaces.contains(List.class)) {
            value = new ArrayList<Object>();
            readCollectionField(json_array.getJSONArray(i), catalog_db, (Collection<?>) value, next_inner_classes);
            // Sets
        } else if (inner_interfaces.contains(Set.class)) {
            value = new HashSet<Object>();
            readCollectionField(json_array.getJSONArray(i), catalog_db, (Collection<?>) value, next_inner_classes);
            // Maps
        } else if (inner_interfaces.contains(Map.class)) {
            value = new HashMap<Object, Object>();
            readMapField(json_array.getJSONObject(i), catalog_db, (Map<Object, Object>) value, next_inner_classes);
            // Values
        } else {
            String json_string = json_array.getString(i);
            value = JSONUtil.getPrimitiveValue(json_string, inner_class, catalog_db);
        }
        collection.add(value);
    } // FOR
    return;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:49,代码来源:JSONUtil.java

示例12: combine

import java.util.Stack; //导入方法依赖的package包/类
/**
 *
 * @param exps
 */
public static AbstractExpression combine(List<AbstractExpression> exps) {
    Stack<AbstractExpression> stack = new Stack<AbstractExpression>();
    stack.addAll(exps);

    if (stack.isEmpty()) {
        return null;
    } else if (stack.size() == 1) {
        return stack.pop();
    }
    AbstractExpression ret = null;
    while (stack.size() > 1) {
        AbstractExpression child_exp = stack.pop();
        //
        // If our return node is null, then we need to make a new one
        //
        if (ret == null) {
            ret = new ConjunctionExpression(ExpressionType.CONJUNCTION_AND);
            ret.setLeft(child_exp);
        //
        // Check whether we can add it to the right side
        //
        } else if (ret.getRight() == null) {
            ret.setRight(child_exp);
            stack.push(ret);
            ret = null;
        }
    }
    if (ret == null) {
        ret = stack.pop();
    } else {
        ret.setRight(stack.pop());
    }
    return ret;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:39,代码来源:ExpressionUtil.java

示例13: canBreak

import java.util.Stack; //导入方法依赖的package包/类
private static float canBreak(Stack<Position> stack, HorizontalBox hbox,
		float width) {
	List<Box> children = hbox.children;
	float[] cumWidth = new float[children.size() + 1];
	cumWidth[0] = 0;
	for (int i = 0; i < children.size(); i++) {
		Box box = children.get(i);
		cumWidth[i + 1] = cumWidth[i] + box.width;
		if (cumWidth[i + 1] > width) {
			int pos = getBreakPosition(hbox, i);
			if (box instanceof HorizontalBox) {
				Stack<Position> newStack = new Stack<Position>();
				float w = canBreak(newStack, (HorizontalBox) box, width
						- cumWidth[i]);
				if (w != box.width
						&& (cumWidth[i] + w <= width || pos == -1)) {
					stack.push(new Position(i - 1, hbox));
					stack.addAll(newStack);
					return cumWidth[i] + w;
				}
			}

			if (pos != -1) {
				stack.push(new Position(pos, hbox));
				return cumWidth[pos];
			}
		}
	}

	return hbox.width;
}
 
开发者ID:daquexian,项目名称:FlexibleRichTextView,代码行数:32,代码来源:BreakFormula.java

示例14: tick

import java.util.Stack; //导入方法依赖的package包/类
public static Result tick(BehaviorTree tree, BehaviorData data)
{
	Cursor cursor = new Cursor(tree, data);

	tree.onStart(data);
	Result r = tree.getRoot().execute(cursor);
	cursor.onTreeResult(r);

	Stack<Node> prevOpenNodes = cursor.getBehaviorData().getData(cursor.getBehaviorTree().id, null).get("_open_nodes", new Stack<Node>());
	Stack<Node> openNodes = new Stack<Node>();
	openNodes.addAll(cursor.getOpenNodes());

	int start = 0;
	for (int i = 0; i < Math.min(prevOpenNodes.size(), openNodes.size()); ++i)
	{
		start = i + 1;
		if (prevOpenNodes.get(i) != openNodes.get(i))
		{
			break;
		}
	}

	for (int i = prevOpenNodes.size() - 1; i >= start; --i)
	{
		prevOpenNodes.get(i).close(cursor);
	}

	cursor.getBehaviorData().getData(cursor.getBehaviorTree().id, null).set("_open_nodes", openNodes);
	return r;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:31,代码来源:BehaviorTree.java

示例15: readMapField

import java.util.Stack; //导入方法依赖的package包/类
/**
 * Read data from the given JSONObject and populate the given Map
 * 
 * @param json_object
 * @param catalog_db
 * @param map
 * @param inner_classes
 * @throws Exception
 */
@SuppressWarnings("unchecked")
protected static void readMapField(final JSONObject json_object, final Database catalog_db, final Map map, final Stack<Class<?>> inner_classes) throws Exception {
    Class<?> key_class = inner_classes.pop();
    Class<?> val_class = inner_classes.pop();
    Collection<Class<?>> val_interfaces = ClassUtil.getInterfaces(val_class);
    final Stack<Class<?>> next_inner_classes = new Stack<Class<?>>();
    
    assert (json_object != null);
    for (String json_key : CollectionUtil.iterable(json_object.keys())) {
        next_inner_classes.clear();
        next_inner_classes.addAll(inner_classes);
        assert (next_inner_classes.equals(inner_classes));

        // KEY
        Object key = JSONUtil.getPrimitiveValue(json_key, key_class, catalog_db);

        // VALUE
        Object object = null;
        if (json_object.isNull(json_key)) {
            // Nothing...
        } else if (val_interfaces.contains(List.class)) {
            object = new ArrayList<Object>();
            readCollectionField(json_object.getJSONArray(json_key), catalog_db, (Collection<?>) object, next_inner_classes);
        } else if (val_interfaces.contains(Set.class)) {
            object = new HashSet<Object>();
            readCollectionField(json_object.getJSONArray(json_key), catalog_db, (Collection<?>) object, next_inner_classes);
        } else if (val_interfaces.contains(Map.class)) {
            object = new HashMap<Object, Object>();
            readMapField(json_object.getJSONObject(json_key), catalog_db, (Map<?,?>) object, next_inner_classes);
        } else {
            String json_string = json_object.getString(json_key);
            try {
                object = JSONUtil.getPrimitiveValue(json_string, val_class, catalog_db);
            } catch (Exception ex) {
                System.err.println("val_interfaces: " + val_interfaces);
                LOG.error("Failed to deserialize value '" + json_string + "' from inner map key '" + json_key + "'");
                throw ex;
            }
        }
        map.put(key, object);
    }
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:52,代码来源:JSONUtil.java


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