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

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

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

Stack.trimToSize介绍

暂无

代码示例

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

public void setFrames(Stack<IAnimationFrame> frames) {
  mFrames = frames;
  frames.trimToSize();
  mNumFrames = frames.capacity();
}

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

/**
 * Calculates the length of the the sub-path in a _transition path, that is used only by a given string.
 *
 * @param str a String corresponding to a _transition path from sourceNode
 * @return an int denoting the size of the sub-path in the _transition path
 * corresponding to {@code str} that is only used by {@code str}
 */
private int calculateSoleTransitionPathLength(String str)
{
  Stack<MDAGNode> transitionPathNodeStack = sourceNode.getTransitionPathNodes(str);
  transitionPathNodeStack.pop();  //The MDAGNode at the top of the stack is not needed
  //(we are processing the outgoing transitions of nodes inside str's _transition path,
  //the outgoing transitions of the MDAGNode at the top of the stack are outside this path)
  transitionPathNodeStack.trimToSize();
  //Process each node in transitionPathNodeStack, using each to determine whether the
  //_transition path corresponding to str is only used by str.  This is true if and only if
  //each node in the _transition path has a single outgoing _transition and is not an accept state.
  while (!transitionPathNodeStack.isEmpty())
  {
    MDAGNode currentNode = transitionPathNodeStack.peek();
    if (currentNode.getOutgoingTransitions().size() <= 1 && !currentNode.isAcceptNode())
      transitionPathNodeStack.pop();
    else
      break;
  }
  /////
  return (transitionPathNodeStack.capacity() - transitionPathNodeStack.size());
}

代码示例来源:origin: pondurii/vrVideo

public void setFrames(Stack<IAnimationFrame> frames) {
  mFrames = frames;
  frames.trimToSize();
  mNumFrames = frames.capacity();
}

代码示例来源:origin: sea-boat/TextAnalyzer

/**
 * Calculates the length of the the sub-path in a transition path, that is used only by a given string.
  * @param str       a String corresponding to a transition path from sourceNode
 * @return          an int denoting the size of the sub-path in the transition path
 *                  corresponding to {@code str} that is only used by {@code str}
 */
private int calculateSoleTransitionPathLength(String str) {
  Stack<MDAGNode> transitionPathNodeStack = sourceNode.getTransitionPathNodes(str);
  transitionPathNodeStack.pop(); //The MDAGNode at the top of the stack is not needed
                  //(we are processing the outgoing transitions of nodes inside str's transition path,
                  //the outgoing transitions of the MDAGNode at the top of the stack are outside this path)
  transitionPathNodeStack.trimToSize();
  //Process each node in transitionPathNodeStack, using each to determine whether the
  //transition path corresponding to str is only used by str.  This is true if and only if
  //each node in the transition path has a single outgoing transition and is not an accept state.
  while (!transitionPathNodeStack.isEmpty()) {
    MDAGNode currentNode = transitionPathNodeStack.peek();
    if (currentNode.getOutgoingTransitions().size() <= 1 && !currentNode.isAcceptNode())
      transitionPathNodeStack.pop();
    else
      break;
  }
  /////
  return (transitionPathNodeStack.capacity() - transitionPathNodeStack.size());
}

代码示例来源:origin: com.hankcs/hanlp

/**
 * Calculates the length of the the sub-path in a _transition path, that is used only by a given string.
 *
 * @param str a String corresponding to a _transition path from sourceNode
 * @return an int denoting the size of the sub-path in the _transition path
 * corresponding to {@code str} that is only used by {@code str}
 */
private int calculateSoleTransitionPathLength(String str)
{
  Stack<MDAGNode> transitionPathNodeStack = sourceNode.getTransitionPathNodes(str);
  transitionPathNodeStack.pop();  //The MDAGNode at the top of the stack is not needed
  //(we are processing the outgoing transitions of nodes inside str's _transition path,
  //the outgoing transitions of the MDAGNode at the top of the stack are outside this path)
  transitionPathNodeStack.trimToSize();
  //Process each node in transitionPathNodeStack, using each to determine whether the
  //_transition path corresponding to str is only used by str.  This is true if and only if
  //each node in the _transition path has a single outgoing _transition and is not an accept state.
  while (!transitionPathNodeStack.isEmpty())
  {
    MDAGNode currentNode = transitionPathNodeStack.peek();
    if (currentNode.getOutgoingTransitions().size() <= 1 && !currentNode.isAcceptNode())
      transitionPathNodeStack.pop();
    else
      break;
  }
  /////
  return (transitionPathNodeStack.capacity() - transitionPathNodeStack.size());
}

相关文章