java.util.Stack.toArray()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(325)

本文整理了Java中java.util.Stack.toArray()方法的一些代码示例,展示了Stack.toArray()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Stack.toArray()方法的具体详情如下:
包路径:java.util.Stack
类名称:Stack
方法名:toArray

Stack.toArray介绍

暂无

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

  1. private static String[] credit_card_number( String[] prefixList, int length, int howMany ) {
  2. Stack<String> result = new Stack<String>();
  3. for ( int i = 0; i < howMany; i++ ) {
  4. int randomArrayIndex = (int) Math.floor( Math.random() * prefixList.length );
  5. String ccnumber = prefixList[randomArrayIndex];
  6. result.push( completed_number( ccnumber, length ) );
  7. }
  8. return result.toArray( new String[result.size()] );
  9. }

代码示例来源:origin: hankcs/HanLP

  1. /**
  2. * 获取唯一一条最短路径,当然最短路径可能不只一条
  3. * @return
  4. */
  5. public Integer[] getBestPath()
  6. {
  7. assert (vertexCount > 2);
  8. Stack<Integer> stack = new Stack<Integer>();
  9. int curNode = vertexCount - 1, curIndex = 0;
  10. QueueElement element;
  11. element = fromArray[curNode - 1][curIndex].GetFirst();
  12. stack.push(curNode);
  13. stack.push(element.from);
  14. curNode = element.from;
  15. while (curNode != 0)
  16. {
  17. element = fromArray[element.from - 1][element.index].GetFirst();
  18. stack.push(element.from);
  19. curNode = element.from;
  20. }
  21. return (Integer[]) stack.toArray();
  22. }

代码示例来源:origin: apache/hive

  1. private void getLocks(Stack<String> names, boolean verify,
  2. boolean fetchData, List<HiveLock> locks, HiveConf conf) throws LockException {
  3. lock.lock();
  4. try {
  5. if (hasLock()) {
  6. getLocks(names.toArray(new String[names.size()]), verify, fetchData, locks, conf);
  7. }
  8. if (children != null) {
  9. for (Map.Entry<String, Node> entry : children.entrySet()) {
  10. names.push(entry.getKey());
  11. entry.getValue().getLocks(names, verify, fetchData, locks, conf);
  12. names.pop();
  13. }
  14. }
  15. } finally {
  16. lock.unlock();
  17. }
  18. }

代码示例来源:origin: apache/drill

  1. private void getLocks(Stack<String> names, boolean verify,
  2. boolean fetchData, List<HiveLock> locks, HiveConf conf) throws LockException {
  3. lock.lock();
  4. try {
  5. if (hasLock()) {
  6. getLocks(names.toArray(new String[names.size()]), verify, fetchData, locks, conf);
  7. }
  8. if (children != null) {
  9. for (Map.Entry<String, Node> entry : children.entrySet()) {
  10. names.push(entry.getKey());
  11. entry.getValue().getLocks(names, verify, fetchData, locks, conf);
  12. names.pop();
  13. }
  14. }
  15. } finally {
  16. lock.unlock();
  17. }
  18. }

代码示例来源:origin: edu.illinois.cs.cogcomp/illinois-core-utilities

  1. public <E> E[] toArray(E[] a) {
  2. return stack.toArray(a);
  3. }
  4. });

代码示例来源:origin: org.apache.velocity/com.springsource.org.apache.velocity

  1. /**
  2. * get the current macro name stack
  3. *
  4. * @return Object[] with the macro name stack contents.
  5. */
  6. public Object[] getMacroNameStack()
  7. {
  8. return macroNameStack.toArray();
  9. }

代码示例来源:origin: org.apache.velocity/com.springsource.org.apache.velocity

  1. /**
  2. * get the current template name stack
  3. *
  4. * @return Object[] with the template name stack contents.
  5. */
  6. public Object[] getTemplateNameStack()
  7. {
  8. return templateNameStack.toArray();
  9. }

代码示例来源:origin: com.bbossgroups/bboss-velocity

  1. /**
  2. * get the current macro name stack
  3. *
  4. * @return Object[] with the macro name stack contents.
  5. */
  6. public Object[] getMacroNameStack()
  7. {
  8. return macroNameStack.toArray();
  9. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.velocity

  1. /**
  2. * get the current macro name stack
  3. *
  4. * @return Object[] with the macro name stack contents.
  5. */
  6. public Object[] getMacroNameStack()
  7. {
  8. return macroNameStack.toArray();
  9. }

代码示例来源:origin: com.sun.xml.bind/jaxb-extra-osgi

  1. /**
  2. * takes a snap shot of traversal to this.errorSnapshot
  3. * so that the user will know what references cause this problem.
  4. */
  5. private void takeSnapshot( ReferenceExp lastExp ) {
  6. errorSnapshot = new ReferenceExp[ traversalStack.size()+1 ];
  7. traversalStack.toArray(errorSnapshot);
  8. errorSnapshot[errorSnapshot.length-1] = lastExp;
  9. }
  10. }

代码示例来源:origin: msv/msv

  1. /**
  2. * takes a snap shot of traversal to this.errorSnapshot
  3. * so that the user will know what references cause this problem.
  4. */
  5. private void takeSnapshot( ReferenceExp lastExp ) {
  6. errorSnapshot = new ReferenceExp[ traversalStack.size()+1 ];
  7. traversalStack.toArray(errorSnapshot);
  8. errorSnapshot[errorSnapshot.length-1] = lastExp;
  9. }
  10. }

代码示例来源:origin: org.apache.velocity/velocity-engine-core

  1. /**
  2. * get the current macro name stack
  3. *
  4. * @return String[] with the macro name stack contents.
  5. */
  6. public String[] getMacroNameStack()
  7. {
  8. return macroNameStack.toArray(new String[macroNameStack.size()]);
  9. }

代码示例来源:origin: beanshell/beanshell

  1. /**
  2. zero based.
  3. */
  4. public NameSpace get(int depth) {
  5. int size = stack.size();
  6. if ( depth >= size )
  7. return NameSpace.JAVACODE;
  8. return stack.toArray(new NameSpace[size])[size-1-depth];
  9. }

代码示例来源:origin: org.openmobster.core/mobileObject

  1. private String getUri()
  2. {
  3. StringBuilder buffer = new StringBuilder();
  4. String[] uriPieces = this.uriStack.toArray(new String[0]);
  5. for(String piece: uriPieces)
  6. {
  7. buffer.append("/"+piece);
  8. }
  9. return buffer.toString();
  10. }
  11. //-----------------------------------------------------------------------------------------------------

代码示例来源:origin: org.jruby/jruby-complete

  1. private void emitEnsureBlocks(IRLoop loop) {
  2. int n = activeEnsureBlockStack.size();
  3. EnsureBlockInfo[] ebArray = activeEnsureBlockStack.toArray(new EnsureBlockInfo[n]);
  4. for (int i = n-1; i >= 0; i--) {
  5. EnsureBlockInfo ebi = ebArray[i];
  6. // For "break" and "next" instructions, we only want to run
  7. // ensure blocks from the loops they are present in.
  8. if (loop != null && ebi.innermostLoop != loop) break;
  9. // Clone into host scope
  10. ebi.cloneIntoHostScope(this);
  11. }
  12. }

代码示例来源:origin: org.jruby/jruby-core

  1. private void emitEnsureBlocks(IRLoop loop) {
  2. int n = activeEnsureBlockStack.size();
  3. EnsureBlockInfo[] ebArray = activeEnsureBlockStack.toArray(new EnsureBlockInfo[n]);
  4. for (int i = n-1; i >= 0; i--) {
  5. EnsureBlockInfo ebi = ebArray[i];
  6. // For "break" and "next" instructions, we only want to run
  7. // ensure blocks from the loops they are present in.
  8. if (loop != null && ebi.innermostLoop != loop) break;
  9. // Clone into host scope
  10. ebi.cloneIntoHostScope(this);
  11. }
  12. }

代码示例来源:origin: net.sourceforge.retroweaver/retroweaver-rt

  1. private void endFormal() {
  2. Type bounds[] = stack.toArray(new Type[stack.size()]);
  3. stack.removeAllElements();
  4. formalTypeParameters.getLast().setBounds(bounds);
  5. }

代码示例来源:origin: org.astrogrid/astrogrid-adqlparser-base

  1. public void setError( String message ) {
  2. Error error = new Error() ;
  3. error.setMessage( message ) ;
  4. Part[] position = new Part[ stack.size() ] ;
  5. position = (Part[])stack.toArray( position ) ;
  6. for( int i=0; i<position.length; i++ ) {
  7. position[i] = newPart( position[i] ) ;
  8. }
  9. error.setPosition( position ) ;
  10. errors.add( error ) ;
  11. }

代码示例来源:origin: org.astrogrid/astrogrid-adqlstox

  1. public void setError( String message ) {
  2. Error error = new Error() ;
  3. error.setMessage( message ) ;
  4. Part[] position = new Part[ stack.size() ] ;
  5. position = (Part[])stack.toArray( position ) ;
  6. for( int i=0; i<position.length; i++ ) {
  7. position[i] = newPart( position[i] ) ;
  8. }
  9. error.setPosition( position ) ;
  10. errors.add( error ) ;
  11. }

代码示例来源:origin: org.eclipse/org.eclipse.jst.pagedesigner

  1. protected void setClipboard(Stack result) {
  2. Node[] nodes = (Node[]) result.toArray(new Node[result.size()]);
  3. StringBuffer sb = new StringBuffer();
  4. for (int i = 0, size = nodes.length; i < size; i++) {
  5. DOMUtil.nodeToString(nodes[i], sb);
  6. }
  7. getClipboard().setContents(
  8. new Object[] { result, sb.toString() },
  9. new Transfer[] { TemplateTransfer.getInstance(),
  10. TextTransfer.getInstance() });
  11. }

相关文章