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


Java Stack.clone方法代码示例

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


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

示例1: printStack

import java.util.Stack; //导入方法依赖的package包/类
public static void printStack(Stack s,String title,JTextArea t)
{
	Stack s1 = (Stack)s.clone();
	String output = newLineStr + title + ":";
	while (!s1.empty())
	{
		Entry entry = (Entry)s1.pop();
		String str = TabConverter.revert(entry.getPart());
		output += (newLineStr + str);
		int tag = entry.getTag();
		if(tag != -1)
			str = " < " + analyser.Analyser.Tags.getString(String.valueOf(tag)) + " > ";
		else str = "";

		output += (str);
	}

	output += newLineStr + "---------------";
	t.append(output);
}
 
开发者ID:tacola-auceg,项目名称:spellchecker_ta,代码行数:21,代码来源:Utils.java

示例2: processPositionalParameter

import java.util.Stack; //导入方法依赖的package包/类
private void processPositionalParameter(Collection<ArgSpec> required, Set<ArgSpec> initialized, Stack<String> args) throws Exception {
    if (tracer.isDebug()) {tracer.debug("Processing next arg as a positional parameter at index=%d. Remainder=%s%n", position, reverse((Stack<String>) args.clone()));}
    int consumed = 0;
    for (PositionalParamSpec positionalParam : commandSpec.positionalParameters()) {
        Range indexRange = positionalParam.index();
        if (!indexRange.contains(position)) {
            continue;
        }
        @SuppressWarnings("unchecked")
        Stack<String> argsCopy = (Stack<String>) args.clone();
        Range arity = positionalParam.arity();
        if (tracer.isDebug()) {tracer.debug("Position %d is in index range %s. Trying to assign args to %s, arity=%s%n", position, indexRange, positionalParam, arity);}
        assertNoMissingParameters(positionalParam, arity.min, argsCopy);
        int originalSize = argsCopy.size();
        applyOption(positionalParam, arity, argsCopy, initialized, "args[" + indexRange + "] at position " + position);
        int count = originalSize - argsCopy.size();
        if (count > 0) { required.remove(positionalParam); }
        consumed = Math.max(consumed, count);
    }
    // remove processed args from the stack
    for (int i = 0; i < consumed; i++) { args.pop(); }
    position += consumed;
    if (tracer.isDebug()) {tracer.debug("Consumed %d arguments, moving position to index %d.%n", consumed, position);}
    if (consumed == 0 && !args.isEmpty()) {
        handleUnmatchedArguments(args.pop());
    }
}
 
开发者ID:remkop,项目名称:picocli,代码行数:28,代码来源:CommandLine.java

示例3: assertNoMissingParameters

import java.util.Stack; //导入方法依赖的package包/类
private void assertNoMissingParameters(Field field, int arity, Stack<String> args) {
    if (arity > args.size()) {
        int actualSize = 0;
        @SuppressWarnings("unchecked")
        Stack<String> copy = (Stack<String>) args.clone();
        while (!copy.isEmpty()) {
            actualSize += split(copy.pop(), field).length;
            if (actualSize >= arity) { return; }
        }
        if (arity == 1) {
            if (field.isAnnotationPresent(Option.class)) {
                throw new MissingParameterException("Missing required parameter for " +
                        optionDescription("", field, 0));
            }
            Range indexRange = Range.parameterIndex(field);
            Help.IParamLabelRenderer labelRenderer = Help.createMinimalParamLabelRenderer();
            String sep = "";
            String names = "";
            int count = 0;
            for (int i = indexRange.min; i < positionalParametersFields.size(); i++) {
                if (Range.parameterArity(positionalParametersFields.get(i)).min > 0) {
                    names += sep + labelRenderer.renderParameterLabel(positionalParametersFields.get(i),
                            Help.Ansi.OFF, Collections.<IStyle>emptyList());
                    sep = ", ";
                    count++;
                }
            }
            String msg = "Missing required parameter";
            Range paramArity = Range.parameterArity(field);
            if (paramArity.isVariable) {
                msg += "s at positions " + indexRange + ": ";
            } else {
                msg += (count > 1 ? "s: " : ": ");
            }
            throw new MissingParameterException(msg + names);
        }
        throw new MissingParameterException(optionDescription("", field, 0) +
                " requires at least " + arity + " values, but only " + args.size() + " were specified.");
    }
}
 
开发者ID:alisianoi,项目名称:lyra2-java,代码行数:41,代码来源:CommandLine.java


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