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

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

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

LinkedList.remove介绍

[英]Retrieves and removes the head (first element) of this list.
[中]

代码示例

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

/**
 * Moves the the index to the top of the MRU List
 *
 * @param index The index to be first in the mru list
 */
public void moveToTop(int index) {
 _mruFileList.add(0, _mruFileList.remove(index));
}

代码示例来源:origin: FudanNLP/fnlp

@Override
public void remove(int i) {
  labels.remove(i);
  scores.remove(i);
  if(evidences.size()>i)
    evidences.remove(i);
}
/**

代码示例来源:origin: naman14/Timber

public void setAndRecordPlayPos(int nextPos) {
  synchronized (this) {
    if (mShuffleMode != SHUFFLE_NONE) {
      mHistory.add(mPlayPos);
      if (mHistory.size() > MAX_HISTORY_SIZE) {
        mHistory.remove(0);
      }
    }
    mPlayPos = nextPos;
  }
}

代码示例来源:origin: DozerMapper/dozer

@SuppressWarnings("unchecked")
public static List<Class<?>> getInterfaceHierarchy(Class<?> srcClass, BeanContainer beanContainer) {
  final List<Class<?>> result = new LinkedList<>();
  Class<?> realClass = getRealClass(srcClass, beanContainer);
  final LinkedList<Class> interfacesToProcess = new LinkedList<>();
  Class[] interfaces = realClass.getInterfaces();
  interfacesToProcess.addAll(Arrays.asList(interfaces));
  while (!interfacesToProcess.isEmpty()) {
    Class<?> iface = interfacesToProcess.remove();
    if (!result.contains(iface)) {
      result.add(iface);
      for (Class subiface : iface.getInterfaces()) {
        // if we haven't processed this interface yet then add it to be processed
        if (!result.contains(subiface)) {
          interfacesToProcess.add(subiface);
        }
      }
    }
  }
  return result;
}

代码示例来源:origin: stanfordnlp/CoreNLP

goldMentionHeadPositions.put(g.headIndex, new LinkedList<>());
goldMentionHeadPositions.get(g.headIndex).add(g);
 p.twinless = false;
 g.twinless = false;
 goldMentionHeadPositions.get(g.headIndex).remove(g);
 if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) {
  goldMentionHeadPositions.remove(g.headIndex);
 r.twinless = false;
 g.twinless = false;
 if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) {
  goldMentionHeadPositions.remove(g.headIndex);

代码示例来源:origin: naman14/Timber

public int getPreviousPlayPosition(boolean removeFromHistory) {
  synchronized (this) {
    if (mShuffleMode == SHUFFLE_NORMAL) {
      final int histsize = mHistory.size();
      if (histsize == 0) {
        return -1;
      }
      final Integer pos = mHistory.get(histsize - 1);
      if (removeFromHistory) {
        mHistory.remove(histsize - 1);
      }
      return pos.intValue();
    } else {
      if (mPlayPos > 0) {
        return mPlayPos - 1;
      } else {
        return mPlaylist.size() - 1;
      }
    }
  }
}

代码示例来源:origin: apache/incubator-dubbo

if (index > history.size() - 1) {
        index = 0;
    String value = history.get(index);
    if (old != null && old >= 0 && old < history.size()) {
      String ov = history.get(old);
      StringBuilder buf = new StringBuilder();
      for (int i = 0; i < ov.length(); i++) {
channel.removeAttribute(HISTORY_INDEX_KEY);
if (CollectionUtils.isNotEmpty(history) && index != null && index >= 0 && index < history.size()) {
  String value = history.get(index);
  if (value != null) {
    byte[] b1 = value.getBytes();
    channel.setAttribute(HISTORY_LIST_KEY, history);
  if (history.isEmpty()) {
    history.addLast(result);
  } else if (!result.equals(history.getLast())) {
    history.remove(result);
    history.addLast(result);
    if (history.size() > 10) {

代码示例来源:origin: Sable/soot

private void finder1(PegCallGraph pcg) {
 Set clinitMethods = pcg.getClinitMethods();
 Iterator it = pcg.iterator();
 while (it.hasNext()) {
  Object head = it.next();
  // breadth first scan
  Set<Object> gray = new HashSet<Object>();
  LinkedList<Object> queue = new LinkedList<Object>();
  queue.add(head);
  while (queue.size() > 0) {
   Object root = queue.getFirst();
   Iterator succsIt = pcg.getSuccsOf(root).iterator();
   while (succsIt.hasNext()) {
    Object succ = succsIt.next();
    if (!gray.contains(succ)) {
     gray.add(succ);
     queue.addLast(succ);
    } else if (clinitMethods.contains(succ)) {
     continue;
    } else {
     multiCalledMethods.add((SootMethod) succ);
    }
   }
   queue.remove(root);
  }
 }
}

代码示例来源:origin: org.apache.spark/spark-core_2.10

int nextIdx = dataPages.indexOf(currentPage) + 1;
if (destructive && currentPage != null) {
 dataPages.remove(currentPage);
 freePage(currentPage);
 nextIdx --;
if (dataPages.size() > nextIdx) {
 currentPage = dataPages.get(nextIdx);
 pageBaseObject = currentPage.getBaseObject();
 offsetInPage = currentPage.getBaseOffset();

代码示例来源:origin: kevin-wayne/algs4

/**
 * Returns the next key that was typed by the user (that your program has not already processed).
 * This method should be preceded by a call to {@link #hasNextKeyTyped()} to ensure
 * that there is a next key to process.
 * This method returns a Unicode character corresponding to the key
 * typed (such as {@code 'a'} or {@code 'A'}).
 * It cannot identify action keys (such as F1 and arrow keys)
 * or modifier keys (such as control).
 *
 * @return the next key typed by the user (that your program has not already processed).
 * @throws NoSuchElementException if there is no remaining key
 */
public static char nextKeyTyped() {
  synchronized (keyLock) {
    if (keysTyped.isEmpty()) {
      throw new NoSuchElementException("your program has already processed all keystrokes");
    }
    return keysTyped.remove(keysTyped.size() - 1);
    // return keysTyped.removeLast();
  }
}

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

private void flush(LinkedList<Request> toFlush)
  throws IOException, RequestProcessorException
{
  if (toFlush.isEmpty())
    return;
  zks.getZKDatabase().commit();
  while (!toFlush.isEmpty()) {
    Request i = toFlush.remove();
    if (nextProcessor != null) {
      nextProcessor.processRequest(i);
    }
  }
  if (nextProcessor != null && nextProcessor instanceof Flushable) {
    ((Flushable)nextProcessor).flush();
  }
}

代码示例来源:origin: Sable/soot

LinkedList<Integer> pathStackIndex = new LinkedList<Integer>();
pathStack.add(from);
pathStackIndex.add(new Integer(0));
int psiMax = (g.getSuccsOf(pathStack.get(0))).size();
int level = 0;
while (pathStackIndex.get(0).intValue() != psiMax) {
 int p = (pathStackIndex.get(level)).intValue();
 List<Unit> succs = g.getSuccsOf((pathStack.get(level)));
  pathStack.remove(level);
  pathStackIndex.remove(level);
  pathStack.add(to);
  return pathStack;

代码示例来源:origin: wiztools/rest-client

void openedFile(File f) {
  // Verify and remove if the same file is already in the list:
  recentFiles.remove(f);
  
  // Now, add:
  recentFiles.addFirst(f);
  
  // Remove the least recently used file from list:
  if(recentFiles.size() == 11) { // store only 10 recent files!
    recentFiles.removeLast();
  }
}

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

@Override
public void visitBlockStatement(BlockStatement block) {
  Set<String> names = new HashSet<String>(varStack.getLast());
  varStack.add(names);
  super.visitBlockStatement(block);
  varStack.remove(names);
}

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

public synchronized SelectorSelection register(AbstractSelectableChannel selectableChannel, Listener listener) throws IOException {
  SelectorSelection selection = null;
  while (selection == null) {
    if (freeWorkers.size() > 0) {
      SelectorWorker worker = freeWorkers.getFirst();
      if (worker.isReleased()) {
        freeWorkers.remove(worker);
      } else {
        worker.retain();
        selection = new SelectorSelection(worker, selectableChannel, listener);
      }
    } else {
      // Worker starts /w retain count of 1
      SelectorWorker worker = new SelectorWorker(this);
      freeWorkers.addFirst(worker);
      selection = new SelectorSelection(worker, selectableChannel, listener);
    }
  }
  return selection;
}

代码示例来源:origin: commons-httpclient/commons-httpclient

/**
 * If available, get a free connection for this host
 *
 * @param hostConfiguration the configuraton for the connection pool
 * @return an available connection for the given config
 */
public synchronized HttpConnection getFreeConnection(HostConfiguration hostConfiguration) {
  HttpConnectionWithReference connection = null;
  
  HostConnectionPool hostPool = getHostPool(hostConfiguration, false);
  if ((hostPool != null) && (hostPool.freeConnections.size() > 0)) {
    connection = (HttpConnectionWithReference) hostPool.freeConnections.removeLast();
    freeConnections.remove(connection);
    // store a reference to this connection so that it can be cleaned up
    // in the event it is not correctly released
    storeReferenceToConnection(connection, hostConfiguration, this);
    if (LOG.isDebugEnabled()) {
      LOG.debug("Getting free connection, hostConfig=" + hostConfiguration);
    }
    // remove the connection from the timeout handler
    idleConnectionHandler.remove(connection);
  } else if (LOG.isDebugEnabled()) {
    LOG.debug("There were no free connections to get, hostConfig=" 
      + hostConfiguration);
  }
  return connection;
}

代码示例来源: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: aa112901/remusic

public void setAndRecordPlayPos(int nextPos) {
  synchronized (this) {
    if (mShuffleMode != SHUFFLE_NONE) {
      mHistory.add(mPlayPos);
      if (mHistory.size() > MAX_HISTORY_SIZE) {
        mHistory.remove(0);
      }
    }
    mPlayPos = nextPos;
  }
}

代码示例来源:origin: stanfordnlp/CoreNLP

goldMentionHeadPositions.put(g.headIndex, new LinkedList<>());
goldMentionHeadPositions.get(g.headIndex).add(g);
 p.hasTwin = true;
 g.hasTwin = true;
 goldMentionHeadPositions.get(g.headIndex).remove(g);
 if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) {
  goldMentionHeadPositions.remove(g.headIndex);
 r.hasTwin = true;
 g.hasTwin = true;
 if(goldMentionHeadPositions.get(g.headIndex).isEmpty()) {
  goldMentionHeadPositions.remove(g.headIndex);

代码示例来源:origin: aa112901/remusic

public int getPreviousPlayPosition(boolean removeFromHistory) {
  synchronized (this) {
    if (mShuffleMode == SHUFFLE_NORMAL) {
      final int histsize = mHistory.size();
      if (histsize == 0) {
        return -1;
      }
      final Integer pos = mHistory.get(histsize - 1);
      if (removeFromHistory) {
        mHistory.remove(histsize - 1);
      }
      return pos.intValue();
    } else {
      if (mPlayPos > 0) {
        return mPlayPos - 1;
      } else {
        return mPlaylist.size() - 1;
      }
    }
  }
}

相关文章