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

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

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

Stack.setSize介绍

暂无

代码示例

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

/**
  Clear any nested diagnostic information if any. This method is
  useful in cases where the same thread can be potentially used
  over and over in different unrelated contexts.
  <p>This method is equivalent to calling the {@link #setMaxDepth}
  method with a zero <code>maxDepth</code> argument.
  
  @since 0.8.4c */
public
static
void clear() {
 Stack stack = getCurrentStack();    
 if(stack != null) 
  stack.setSize(0);    
}

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

/**
  Set maximum depth of this diagnostic context. If the current
  depth is smaller or equal to <code>maxDepth</code>, then no
  action is taken.
  <p>This method is a convenient alternative to multiple {@link
  #pop} calls. Moreover, it is often the case that at the end of
  complex call sequences, the depth of the NDC is
  unpredictable. The <code>setMaxDepth</code> method circumvents
  this problem.
  <p>For example, the combination
  <pre>
   void foo() {
   &nbsp;  int depth = NDC.getDepth();
   &nbsp;  ... complex sequence of calls
   &nbsp;  NDC.setMaxDepth(depth);
   }
  </pre>
  ensures that between the entry and exit of foo the depth of the
  diagnostic stack is conserved.
  
  @see #getDepth
  @since 0.7.5 */
static
public
void setMaxDepth(int maxDepth) {
 Stack stack = getCurrentStack();    
 if(stack != null && maxDepth < stack.size()) 
  stack.setSize(maxDepth);
}

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

/**
  Clear any nested diagnostic information if any. This method is
  useful in cases where the same thread can be potentially used
  over and over in different unrelated contexts.
  <p>This method is equivalent to calling the {@link #setMaxDepth}
  method with a zero <code>maxDepth</code> argument.
  
  @since 0.8.4c */
public
static
void clear() {
 Stack stack = getCurrentStack();    
 if(stack != null) {
   stack.setSize(0);
 }    
}

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

Stack stack = getCurrentStack();    
if(stack != null && maxDepth < stack.size()) {
  stack.setSize(maxDepth);

代码示例来源:origin: org.daisy.libs/jing

public void reset() {
 openElements.setSize(0);
 valueHandlers.setSize(0);
 activePatterns.setSize(0);
 locator = null;
}

代码示例来源:origin: com.thaiopensource/jing

public void reset() {
 openElements.setSize(0);
 valueHandlers.setSize(0);
 activePatterns.setSize(0);
 locator = null;
}

代码示例来源:origin: org.eclipse.persistence/org.eclipse.persistence.jpa.jpql

/**
 * Disposes of the internal data.
 */
public void dispose() {
  word          = null;
  proposals     = null;
  wordParser    = null;
  queryPosition = null;
  // Not required but during debugging, this is important to be reset
  corrections.setSize(1);
  virtualSpaces.setSize(1);
  lockedExpressions.clear();
}

代码示例来源:origin: org.jboss.jreadline/jreadline

public UndoManager() {
  undoStack = new Stack<UndoAction>();
  undoStack.setSize(UNDO_SIZE);
  counter = 0;
}

代码示例来源:origin: org.aesh/aesh-readline

public UndoManager() {
  undoStack = new Stack<>();
  undoStack.setSize(UNDO_SIZE);
  counter = 0;
}

代码示例来源:origin: org.specs2/classycle

protected void initializeProcessing(Vertex[] graph) {
 _counter = 0;
 _vertexStack.setSize(0);
 _strongComponents.setSize(0);
 _vertexToComponents.clear();
}

代码示例来源:origin: org.eclipse/org.eclipse.wst.common.frameworks.ui

private void restoreStackInfo() {
  if (savedStackSize == 0) {
    pageGroupStack.removeAllElements();
  } else {
    pageGroupStack.setSize(savedStackSize - 1);
    pageGroupStack.push(savedTopEntry);
  }
}

代码示例来源:origin: EvoSuite/evosuite

private Stack<MethodCall> copyCallStack(Stack<MethodCall> callStack) {
  Stack<MethodCall> r = new Stack<MethodCall>();
  r.setSize(callStack.size());
  Collections.copy(r, callStack);
  return r;
}

代码示例来源:origin: grzegorznittner/chanu

protected synchronized void storeDataTransfer(int time, int size) {
  DataTransfer transfer = new DataTransfer(time, size);
  dataTransfers.push(transfer);
  if (DEBUG) Log.i(TAG, "Storing transfer " + transfer);
  if (dataTransfers.size() > MAX_STORED_DATATRANSFERS) {
    dataTransfers.setSize(MAX_STORED_DATATRANSFERS);
  }
}

代码示例来源:origin: grzegorznittner/chanu

protected synchronized void storeFailedDataTransfer() {
  DataTransfer transfer = new DataTransfer();
  dataTransfers.push(transfer);
  if (DEBUG) Log.i(TAG, "Storing transfer " + transfer);
  if (dataTransfers.size() > MAX_STORED_DATATRANSFERS) {
    dataTransfers.setSize(MAX_STORED_DATATRANSFERS);
  }
}

代码示例来源:origin: org.apache.activemq/activemq-all

/**
  Clear any nested diagnostic information if any. This method is
  useful in cases where the same thread can be potentially used
  over and over in different unrelated contexts.
  <p>This method is equivalent to calling the {@link #setMaxDepth}
  method with a zero <code>maxDepth</code> argument.
  
  @since 0.8.4c */
public
static
void clear() {
 Stack stack = getCurrentStack();    
 if(stack != null) 
  stack.setSize(0);    
}

代码示例来源:origin: com.impetus.fabric/fabric-jdbc-driver-shaded

/**
  Clear any nested diagnostic information if any. This method is
  useful in cases where the same thread can be potentially used
  over and over in different unrelated contexts.
  <p>This method is equivalent to calling the {@link #setMaxDepth}
  method with a zero <code>maxDepth</code> argument.
  
  @since 0.8.4c */
public
static
void clear() {
 Stack stack = getCurrentStack();    
 if(stack != null) 
  stack.setSize(0);    
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-editor

public void popBrace(ExtendedTokenSequence ts) {
  int brace = 0;
  for (int i = stack.size() - 1; i >= 0; i--) {
    StackEntry top = stack.get(i);
    if (top.getKind() == LBRACE) {
      brace = i - 1;
      stack.setSize(i);
      break;
    }
  }
  if (brace < 0) {
    stack.setSize(0);
    return;
  }
  popStatement(ts);
}

代码示例来源:origin: eiiches/jackson-jq

private void recursive(final Scope scope, final JsonNode in, final Functional.Consumer<List<Pair<String, JsonNode>>> out, final Stack<Pair<String, JsonNode>> accumulate, final boolean emit, int index) throws JsonQueryException {
  if (index >= matchers.size())
    return;
  final Pair<JsonQuery, PatternMatcher> kvexpr = matchers.get(index);
  final JsonQuery keyexpr = kvexpr._1;
  final PatternMatcher matcher = kvexpr._2;
  for (final JsonNode key : keyexpr.apply(scope, in)) {
    if (!key.isTextual())
      throw JsonQueryTypeException.format("Cannot index %s with %s", in.getNodeType(), key.getNodeType());
    final JsonNode value = in.get(key.asText());
    final int size = accumulate.size();
    matcher.match(scope, value != null ? value : NullNode.getInstance(), out, accumulate, emit && index == matchers.size() - 1);
    recursive(scope, in, out, accumulate, emit, index + 1);
    accumulate.setSize(size);
  }
}

代码示例来源:origin: com.thaiopensource/jing

private void endPath() throws SAXException {
 if (!currentElementAction.contextMap.put(isRoot, nameStack, contextMode))
  error("path_multiply_defined", displayPath(isRoot, nameStack));
 elementNs = contextNs;
 isRoot = false;
 nameStack.setSize(0);
}

代码示例来源:origin: org.daisy.libs/jing

private void endPath() throws SAXException {
 if (!currentElementAction.contextMap.put(isRoot, nameStack, contextMode))
  error("path_multiply_defined", displayPath(isRoot, nameStack));
 elementNs = contextNs;
 isRoot = false;
 nameStack.setSize(0);
}

相关文章