java.util.LinkedList.clear()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(226)

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

LinkedList.clear介绍

[英]Removes all of the elements from this list. The list will be empty after this call returns.
[中]从此列表中删除所有元素。此调用返回后,列表将为空。

代码示例

代码示例来源:origin: prestodb/presto

public void reset() {
  _pastLen = 0;
  _currBlockPtr = 0;
  if (!_pastBlocks.isEmpty()) {
    _pastBlocks.clear();
  }
}

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

private void drainNewRequestList() {
 synchronized (newRequestList) {
  if (!newRequestList.isEmpty()) {
   pendingRequests.addAll(newRequestList);
   newRequestList.clear();
  }
 }
}

代码示例来源:origin: org.codehaus.groovy/groovy

protected static long handleMatches(long matchesDistance, LinkedList matches, Object method, long dist) {
  if (matches.isEmpty()) {
    matches.add(method);
    matchesDistance = dist;
  } else if (dist < matchesDistance) {
    matchesDistance = dist;
    matches.clear();
    matches.add(method);
  } else if (dist == matchesDistance) {
    matches.add(method);
  }
  return matchesDistance;
}

代码示例来源:origin: fesh0r/fernflower

private static Statement findFirstBlock(Statement stat, Set<Statement> setStats) {
 LinkedList<Statement> stack = new LinkedList<>();
 stack.add(stat);
 while (!stack.isEmpty()) {
  Statement st = stack.remove(0);
  if (stack.isEmpty() || setStats.contains(st)) {
   if (st.isLabeled() && !stack.isEmpty() || st.getExprents() != null) {
    return st;
   }
   stack.clear();
   switch (st.type) {
    case Statement.TYPE_SEQUENCE:
     stack.addAll(0, st.getStats());
     break;
    case Statement.TYPE_IF:
    case Statement.TYPE_ROOT:
    case Statement.TYPE_SWITCH:
    case Statement.TYPE_SYNCRONIZED:
     stack.add(st.getFirst());
     break;
    default:
     return st;
   }
  }
 }
 return null;
}

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

public void clear() {
  writeLock.lock();
  try {
    messageIdPartitionMap.clear();
    timePartitions.clear();
    int blankPartitions = (int)Math.ceil((double)ackTimeoutMillis / tickDurationInMs);
    for (int i = 0; i < blankPartitions + 1; i++) {
      timePartitions.add(new ConcurrentOpenHashSet<>());
    }
  } finally {
    writeLock.unlock();
  }
}

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Start buffering events
 * @param eventLimit the maximum number of events to buffer. -1 will buffer all events, 0 will buffer no events.
 */
public void mark(int eventLimit) {
  this.eventLimit = eventLimit;
  //Buffering no events now, clear the buffer and buffered reader
  if (this.eventLimit == 0) {
    this.eventBuffer.clear();
    this.bufferReader = null;
  }
  //Buffering limited set of events, lets trim the buffer if needed
  else if (this.eventLimit > 0) {
    //If there is an iterator check its current position and calculate the new iterator start position
    int iteratorIndex = 0;
    if (this.bufferReader != null) {
      final int nextIndex = this.bufferReader.nextIndex();
      iteratorIndex = Math.max( 0, nextIndex - ( this.eventBuffer.size() - this.eventLimit ) );
    }
    //Trim the buffer until it is not larger than the limit
    while (this.eventBuffer.size() > this.eventLimit) {
      this.eventBuffer.poll();
    }
    //If there is an iterator re-create it using the newly calculated index
    if (this.bufferReader != null) {
      this.bufferReader = this.eventBuffer.listIterator(iteratorIndex);
    }
  }
}

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

confValue = null;
  confFinal = false;
  confSource.clear();
      confFinal = "true".equals(reader.getAttributeValue(i));
    } else if ("source".equals(propertyAttr)) {
      confSource.add(StringInterner.weakIntern(
          reader.getAttributeValue(i)));
  break;
case "source":
  confSource.add(StringInterner.weakIntern(token.toString()));
  break;
case "include":
    break;
  confSource.add(name);
  DeprecatedKeyInfo keyInfo =
      deprecations.getDeprecatedKeyMap().get(confName);
          confSource.toArray(new String[confSource.size()]));
        confSource.toArray(new String[confSource.size()]));

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

debugAppState.addArmatureFrom(sc);
anims.clear();
for (String name : composer.getAnimClipsNames()) {
  anims.add(name);
anims.addFirst("Sequence1");
if (anims.isEmpty()) {
  return;
  anims.add(anim);
  composer.setCurrentAction(anim);
  System.err.println(anim);

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

synchronized (deliveredMessages) {
  if (clearDeliveredList) {
    if (!deliveredMessages.isEmpty()) {
      if (session.isTransacted()) {
             getConsumerId(), previouslyDeliveredMessages.transactionId, deliveredMessages.size());
      } else {
        if (session.isClientAcknowledge()) {
          LOG.debug("{} rolling back delivered list ({}) on transport interrupt", getConsumerId(), deliveredMessages.size());
        LOG.debug("{} clearing delivered list ({}) on transport interrupt", getConsumerId(), deliveredMessages.size());
        deliveredMessages.clear();
        pendingAck = null;

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

cq = q;
      selected.clear();
      selected.add(v);
    } else if (q > cq) {
      cq = q;
      selected.add(v);
selected.add(v);

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

@Override
protected void doRollback() throws InterruptedException {
 if (type.equals(TransactionType.NONE)) {
  return;
 }
 if (type.equals(TransactionType.PUT)) {
  producerRecords.get().clear();
  kafkaFutures.get().clear();
 } else {
  counter.addToRollbackCounter(events.get().size());
  consumerAndRecords.get().failedEvents.addAll(events.get());
  events.get().clear();
 }
}

代码示例来源:origin: stackoverflow.com

clear=true;
curLength=0;
lengths.clear();
values.clear();
if(queue) { queue=false; EventQueue.invokeLater(this); }
  curLength+=val.length();
  if(val.endsWith(EOL1) || val.endsWith(EOL2)) {
    if(lengths.size()>=maxLines) { textArea.replaceRange("",0,lengths.removeFirst()); }
    lengths.addLast(curLength);
    curLength=0;

代码示例来源:origin: fesh0r/fernflower

private Statement findFirstBlock(Statement stat, Integer varindex) {
 stack.add(stat);
 while (!stack.isEmpty()) {
  Statement st = stack.remove(0);
  if (stack.isEmpty() || mapStatementVars.get(st.id).contains(varindex)) {
   if (st.isLabeled() && !stack.isEmpty()) {
    return st;
    stack.clear();
     case Statement.TYPE_SWITCH:
     case Statement.TYPE_SYNCRONIZED:
      stack.add(st.getFirst());
      break;
     default:

代码示例来源:origin: iSoron/uhabits

private synchronized void loadFromParent()
{
  if (parent == null) throw new IllegalStateException();
  list.clear();
  for (Habit h : parent) if (filter.matches(h)) list.add(h);
  resort();
}

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

public ASTNode depthFirstSearch(ASTNode ast, int token) {
 searchQueue.clear();
 searchQueue.add(ast);
 while (!searchQueue.isEmpty()) {
  ASTNode next = searchQueue.poll();
  if (next.getType() == token) return next;
  for (int j = 0; j < next.getChildCount(); ++j) {
   searchQueue.add((ASTNode) next.getChild(j));
  }
 }
 return null;
}

代码示例来源:origin: hibernate/hibernate-orm

/**
 * Start buffering events
 * @param eventLimit the maximum number of events to buffer. -1 will buffer all events, 0 will buffer no events.
 */
public void mark(int eventLimit) {
  this.eventLimit = eventLimit;
  //Buffering no events now, clear the buffer and buffered reader
  if (this.eventLimit == 0) {
    this.eventBuffer.clear();
    this.bufferReader = null;
  }
  //Buffering limited set of events, lets trim the buffer if needed
  else if (this.eventLimit > 0) {
    //If there is an iterator check its current position and calculate the new iterator start position
    int iteratorIndex = 0;
    if (this.bufferReader != null) {
      final int nextIndex = this.bufferReader.nextIndex();
      iteratorIndex = Math.max(0, nextIndex - (this.eventBuffer.size() - this.eventLimit));
    }
    //Trim the buffer until it is not larger than the limit
    while (this.eventBuffer.size() > this.eventLimit) {
      this.eventBuffer.poll();
    }
    //If there is an iterator re-create it using the newly calculated index
    if (this.bufferReader != null) {
      this.bufferReader = this.eventBuffer.listIterator(iteratorIndex);
    }
  }
}

代码示例来源:origin: jMonkeyEngine/jmonkeyengine

void assemble(Letters quads) {
  pageQuads.clear();
  quads.rewind();
    if (quads.isPrintable()) {
      if (quads.getCharacterSetPage() == page) {
        pageQuads.add(quads.getQuad());
  int vertCount = pageQuads.size() * 4;
  int triCount = pageQuads.size() * 2;
    for (int i = 0; i < pageQuads.size(); i++) {
      LetterQuad fq = pageQuads.get(i);
      fq.storeToArrays(pos, tc, idx, color, i);

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

public void reset() {
  _pastLen = 0;
  _currBlockPtr = 0;
  if (!_pastBlocks.isEmpty()) {
    _pastBlocks.clear();
  }
}

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

for (int i = 0; (i < deliveredMessages.size()) && (i < ackCounter); i++) {
if (deliveredMessages.isEmpty()) {
  return;
  MessageAck ack = new MessageAck(lastMd, MessageAck.POSION_ACK_TYPE, deliveredMessages.size());
  ack.setFirstMessageId(firstMsgId);
  ack.setPoisonCause(new Throwable("Delivery[" + lastMd.getMessage().getRedeliveryCounter()  + "] exceeds redelivery policy limit:" + redeliveryPolicy
  session.sendAck(ack,true);
  additionalWindowSize = Math.max(0, additionalWindowSize - deliveredMessages.size());
  redeliveryDelay = 0;
  deliveredCounter -= deliveredMessages.size();
  deliveredMessages.clear();
      deliveredCounter -= deliveredMessages.size();
      deliveredMessages.clear();
    deliveredCounter -= deliveredMessages.size();
    deliveredMessages.clear();

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

cq = q;
      selected.clear();
      selected.add(v);
    } else if (q > cq) {
      cq = q;
      selected.add(v);
selected.add(v);

相关文章