本文整理汇总了Java中java.util.Stack.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java Stack.toArray方法的具体用法?Java Stack.toArray怎么用?Java Stack.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Stack
的用法示例。
在下文中一共展示了Stack.toArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBestPath
import java.util.Stack; //导入方法依赖的package包/类
/**
* 获取唯一一条最短路径,当然最短路径可能不只一条
* @return
*/
public Integer[] getBestPath()
{
assert (vertexCount > 2);
Stack<Integer> stack = new Stack<Integer>();
int curNode = vertexCount - 1, curIndex = 0;
QueueElement element;
element = fromArray[curNode - 1][curIndex].GetFirst();
stack.push(curNode);
stack.push(element.from);
curNode = element.from;
while (curNode != 0)
{
element = fromArray[element.from - 1][element.index].GetFirst();
stack.push(element.from);
curNode = element.from;
}
return (Integer[]) stack.toArray();
}
示例2: readArray
import java.util.Stack; //导入方法依赖的package包/类
@Override
public String[] readArray(JsonReader reader) {
Stack<String> stringStack = new Stack<>();
reader.beginArray();
while (JsonToken.END_ARRAY != reader.peek()) {
if (JsonToken.NULL == reader.peek()) {
reader.skipValue();
stringStack.push(null);
} else {
stringStack.push(reader.nextString());
}
}
reader.endArray();
return stringStack.toArray(new String[stringStack.size()]);
}
示例3: path
import java.util.Stack; //导入方法依赖的package包/类
public String path(final Stack<BuildRule> stack, final String child) {
final StringBuilder sb = new StringBuilder();
final BuildRule[] a = stack.toArray(new BuildRule[stack.size()]);
for (final BuildRule r : a) {
sb.append(r.getName())
.append(':');
}
sb.append(child);
return sb.toString();
}
示例4: buildNodeName
import java.util.Stack; //导入方法依赖的package包/类
private static String buildNodeName(Stack<Integer> integerStack) {
StringBuilder stringBuilder = new StringBuilder("Name-->");
Integer[] indexArray = integerStack.toArray(new Integer[0]);
stringBuilder.append(indexArray[0]);
for (int i = 1; i < indexArray.length; i++) {
stringBuilder.append('-').append(indexArray[i]);
}
return stringBuilder.toString();
}