本文整理了Java中java.util.List.remove()
方法的一些代码示例,展示了List.remove()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.remove()
方法的具体详情如下:
包路径:java.util.List
类名称:List
方法名:remove
[英]Removes the object at the specified location from this List.
[中]从此列表中删除指定位置处的对象。
代码示例来源:origin: square/okhttp
private void removeAllCanonicalQueryParameters(String canonicalName) {
for (int i = encodedQueryNamesAndValues.size() - 2; i >= 0; i -= 2) {
if (canonicalName.equals(encodedQueryNamesAndValues.get(i))) {
encodedQueryNamesAndValues.remove(i + 1);
encodedQueryNamesAndValues.remove(i);
if (encodedQueryNamesAndValues.isEmpty()) {
encodedQueryNamesAndValues = null;
return;
}
}
}
}
代码示例来源:origin: square/okhttp
public Builder removeAll(String name) {
for (int i = 0; i < namesAndValues.size(); i += 2) {
if (name.equalsIgnoreCase(namesAndValues.get(i))) {
namesAndValues.remove(i); // name
namesAndValues.remove(i); // value
i -= 2;
}
}
return this;
}
代码示例来源:origin: google/guava
<E> E pop(List<E> stack) {
return stack.remove(stack.size() - 1);
}
};
代码示例来源:origin: Bilibili/DanmakuFlameMaster
private void setDanmakuVisible(boolean visible, int type) {
if (visible) {
mFilterTypes.remove(Integer.valueOf(type));
} else if (!mFilterTypes.contains(Integer.valueOf(type))) {
mFilterTypes.add(type);
}
}
代码示例来源:origin: skylot/jadx
public void addRecentFile(String filePath) {
recentFiles.remove(filePath);
recentFiles.add(0, filePath);
int count = recentFiles.size();
if (count > RECENT_FILES_COUNT) {
recentFiles.subList(RECENT_FILES_COUNT, count).clear();
}
partialSync(settings -> settings.recentFiles = recentFiles);
}
代码示例来源:origin: ReactiveX/RxJava
List<Integer> list = new VolatileSizeArrayList<Integer>();
assertTrue(list.isEmpty());
assertEquals(0, list.size());
assertFalse(list.contains(1));
assertFalse(list.remove((Integer)1));
assertTrue(list.contains(2));
assertFalse(list.remove((Integer)10));
assertFalse(list.isEmpty());
assertEquals(7, list.size());
assertEquals(7, list.size());
assertEquals(i, list.get(i - 1).intValue());
assertFalse(list.equals(list3));
assertEquals(list.toString(), list3.toString());
list.remove(0);
assertEquals(6, list.size());
assertEquals(0, list.size());
assertTrue(list.isEmpty());
代码示例来源:origin: square/okhttp
public Builder removePathSegment(int index) {
encodedPathSegments.remove(index);
if (encodedPathSegments.isEmpty()) {
encodedPathSegments.add(""); // Always leave at least one '/'.
}
return this;
}
代码示例来源:origin: google/ExoPlayer
private void moveMediaSourceInternal(int currentIndex, int newIndex) {
int startIndex = Math.min(currentIndex, newIndex);
int endIndex = Math.max(currentIndex, newIndex);
int windowOffset = mediaSourceHolders.get(startIndex).firstWindowIndexInChild;
int periodOffset = mediaSourceHolders.get(startIndex).firstPeriodIndexInChild;
mediaSourceHolders.add(newIndex, mediaSourceHolders.remove(currentIndex));
for (int i = startIndex; i <= endIndex; i++) {
MediaSourceHolder holder = mediaSourceHolders.get(i);
holder.firstWindowIndexInChild = windowOffset;
holder.firstPeriodIndexInChild = periodOffset;
windowOffset += holder.timeline.getWindowCount();
periodOffset += holder.timeline.getPeriodCount();
}
}
代码示例来源:origin: spring-projects/spring-framework
@Override
public void addBeanPostProcessor(BeanPostProcessor beanPostProcessor) {
Assert.notNull(beanPostProcessor, "BeanPostProcessor must not be null");
// Remove from old position, if any
this.beanPostProcessors.remove(beanPostProcessor);
// Track whether it is instantiation/destruction aware
if (beanPostProcessor instanceof InstantiationAwareBeanPostProcessor) {
this.hasInstantiationAwareBeanPostProcessors = true;
}
if (beanPostProcessor instanceof DestructionAwareBeanPostProcessor) {
this.hasDestructionAwareBeanPostProcessors = true;
}
// Add to end of list
this.beanPostProcessors.add(beanPostProcessor);
}
代码示例来源:origin: jenkinsci/jenkins
fragments.add(ef.refresh());
while (!newFinders.isEmpty()) {
ExtensionFinder f = newFinders.remove(newFinders.size()-1).getInstance();
if (!actions.contains(a)) actions.add(a);
代码示例来源:origin: commonsguy/cw-omnibus
public boolean addOpenEditor(Uri document) {
List<Uri> current=getOpenEditors();
if (!current.contains(document)) {
if (current.size()>9) {
current.remove(0);
}
current.add(document);
return(saveHistory(current));
}
return(true);
}
代码示例来源:origin: alibaba/canal
public synchronized void subscribe(ClientIdentity clientIdentity) throws CanalMetaManagerException {
List<ClientIdentity> clientIdentitys = destinations.get(clientIdentity.getDestination());
if (clientIdentitys.contains(clientIdentity)) {
clientIdentitys.remove(clientIdentity);
}
clientIdentitys.add(clientIdentity);
}
代码示例来源:origin: apache/kafka
private void processPartitionMovement(TopicPartition partition,
String newConsumer,
Map<String, List<TopicPartition>> currentAssignment,
TreeSet<String> sortedCurrentSubscriptions,
Map<TopicPartition, String> currentPartitionConsumer) {
String oldConsumer = currentPartitionConsumer.get(partition);
sortedCurrentSubscriptions.remove(oldConsumer);
sortedCurrentSubscriptions.remove(newConsumer);
partitionMovements.movePartition(partition, oldConsumer, newConsumer);
currentAssignment.get(oldConsumer).remove(partition);
currentAssignment.get(newConsumer).add(partition);
currentPartitionConsumer.put(partition, newConsumer);
sortedCurrentSubscriptions.add(newConsumer);
sortedCurrentSubscriptions.add(oldConsumer);
}
代码示例来源:origin: google/ExoPlayer
@Override
public void releasePeriod(MediaPeriod mediaPeriod) {
DeferredMediaPeriod deferredMediaPeriod = (DeferredMediaPeriod) mediaPeriod;
List<DeferredMediaPeriod> mediaPeriods =
deferredMediaPeriodByAdMediaSource.get(deferredMediaPeriod.mediaSource);
if (mediaPeriods != null) {
mediaPeriods.remove(deferredMediaPeriod);
}
deferredMediaPeriod.releasePeriod();
}
代码示例来源:origin: apache/kafka
public void maybeRemoveFromInflightBatches(ProducerBatch batch) {
List<ProducerBatch> batches = inFlightBatches.get(batch.topicPartition);
if (batches != null) {
batches.remove(batch);
if (batches.isEmpty()) {
inFlightBatches.remove(batch.topicPartition);
}
}
}
代码示例来源:origin: apache/incubator-druid
/**
* Removes the latest holder, so that {@link #get()} returns the next one.
*/
void next()
{
if (!holders.isEmpty()) {
holders.remove(holders.size() - 1);
}
}
}
代码示例来源:origin: stanfordnlp/CoreNLP
@Override
public E next() {
if (!hasNext()) {
throw new IllegalArgumentException("Iterator is empty!");
}
E next = iters.get(0).next();
lastIter = iters.get(0);
while (!iters.isEmpty() && !iters.get(0).hasNext()) {
iters.remove(0);
}
return next;
}
@Override
代码示例来源:origin: stanfordnlp/CoreNLP
private void removeBaselineFeature(String featName) {
if(baselineFeatures.contains(featName)) {
baselineFeatures.remove(featName);
Pair<TregexPattern,Function<TregexMatcher,String>> p = annotationPatterns.get(featName);
activeAnnotations.remove(p);
}
}
代码示例来源:origin: spring-projects/spring-framework
private ModelMethod getNextModelMethod(ModelAndViewContainer container) {
for (ModelMethod modelMethod : this.modelMethods) {
if (modelMethod.checkDependencies(container)) {
this.modelMethods.remove(modelMethod);
return modelMethod;
}
}
ModelMethod modelMethod = this.modelMethods.get(0);
this.modelMethods.remove(modelMethod);
return modelMethod;
}
代码示例来源:origin: google/guava
public static void assertContainsAllOf(Iterable<?> actual, Object... expected) {
List<Object> expectedList = new ArrayList<>();
expectedList.addAll(Arrays.asList(expected));
for (Object o : actual) {
expectedList.remove(o);
}
if (!expectedList.isEmpty()) {
Assert.fail("Not true that " + actual + " contains all of " + Arrays.asList(expected));
}
}
内容来源于网络,如有侵权,请联系作者删除!