当前位置: 首页>>代码示例>>Java>>正文


Java Iterator.remove方法代码示例

本文整理汇总了Java中java.util.Iterator.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Iterator.remove方法的具体用法?Java Iterator.remove怎么用?Java Iterator.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.Iterator的用法示例。


在下文中一共展示了Iterator.remove方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeParameter

import java.util.Iterator; //导入方法依赖的package包/类
/**
 * Removes all parameters with the given paramName. If there is more than
 * one parameter with the given paramName, all of them are removed.  If
 * there is just one, it is removed.  If there are none, then the request
 * is ignored.
 *
 * @param paramName The parameter name to remove.
 *
 * @return true if at least one parameter was removed
 *
 * @throws IllegalArgumentException When the parameter name passed is null
 *
 * @since 2.0
 */
public boolean removeParameter(String paramName) 
throws IllegalArgumentException {
    LOG.trace("enter PostMethod.removeParameter(String)");

    if (paramName == null) {
        throw new IllegalArgumentException(
            "Argument passed to removeParameter(String) cannot be null");
    }
    boolean removed = false;
    Iterator iter = this.params.iterator();

    while (iter.hasNext()) {
        NameValuePair pair = (NameValuePair) iter.next();

        if (paramName.equals(pair.getName())) {
            iter.remove();
            removed = true;
        }
    }
    return removed;
}
 
开发者ID:jenkinsci,项目名称:lib-commons-httpclient,代码行数:36,代码来源:PostMethod.java

示例2: iteratorRemoveFromCache

import java.util.Iterator; //导入方法依赖的package包/类
@Test public void iteratorRemoveFromCache() throws Exception {
  // Put a response in the cache.
  server.enqueue(new MockResponse()
      .addHeader("Cache-Control: max-age=60")
      .setBody("a"));
  HttpUrl url = server.url("/a");
  assertEquals("a", get(url).body().string());

  // Remove it with iteration.
  Iterator<String> i = cache.urls();
  assertEquals(url.toString(), i.next());
  i.remove();

  // Confirm that subsequent requests suffer a cache miss.
  server.enqueue(new MockResponse()
      .setBody("b"));
  assertEquals("b", get(url).body().string());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:19,代码来源:CacheTest.java

示例3: getStructureVillageWeightedPieceList

import java.util.Iterator; //导入方法依赖的package包/类
public static List<StructureVillagePieces.PieceWeight> getStructureVillageWeightedPieceList(Random random, int size)
{
    List<StructureVillagePieces.PieceWeight> list = Lists.<StructureVillagePieces.PieceWeight>newArrayList();
    list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House4Garden.class, 4, MathHelper.getRandomIntegerInRange(random, 2 + size, 4 + size * 2)));
    list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Church.class, 20, MathHelper.getRandomIntegerInRange(random, 0 + size, 1 + size)));
    list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House1.class, 20, MathHelper.getRandomIntegerInRange(random, 0 + size, 2 + size)));
    list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.WoodHut.class, 3, MathHelper.getRandomIntegerInRange(random, 2 + size, 5 + size * 3)));
    list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Hall.class, 15, MathHelper.getRandomIntegerInRange(random, 0 + size, 2 + size)));
    list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Field1.class, 3, MathHelper.getRandomIntegerInRange(random, 1 + size, 4 + size)));
    list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.Field2.class, 3, MathHelper.getRandomIntegerInRange(random, 2 + size, 4 + size * 2)));
    list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House2.class, 15, MathHelper.getRandomIntegerInRange(random, 0, 1 + size)));
    list.add(new StructureVillagePieces.PieceWeight(StructureVillagePieces.House3.class, 8, MathHelper.getRandomIntegerInRange(random, 0 + size, 3 + size * 2)));
    net.minecraftforge.fml.common.registry.VillagerRegistry.addExtraVillageComponents(list, random, size);
    Iterator<StructureVillagePieces.PieceWeight> iterator = list.iterator();

    while (iterator.hasNext())
    {
        if (((StructureVillagePieces.PieceWeight)iterator.next()).villagePiecesLimit == 0)
        {
            iterator.remove();
        }
    }

    return list;
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:26,代码来源:StructureVillagePieces.java

示例4: cleanup

import java.util.Iterator; //导入方法依赖的package包/类
public void cleanup() throws ResourceException {
  if (DEBUG) {
    try {
      throw new NullPointerException("Asif:JCAManagedConnection:cleanup");
    } catch (NullPointerException npe) {
      npe.printStackTrace();
    }
  }
  synchronized (this.connections) {
    Iterator<GFConnectionImpl> connsItr = this.connections.iterator();
    while (connsItr.hasNext()) {
      GFConnectionImpl conn = connsItr.next();
      conn.invalidate();
      connsItr.remove();
    }
  }
  if (this.localTran == null || this.localTran.transactionInProgress()) {
    if (this.initDone && !this.cache.isClosed()) {
      this.localTran = new JCALocalTransaction(cache, gfTxMgr);
    } else {
      this.localTran = new JCALocalTransaction();
    }
  }

}
 
开发者ID:ampool,项目名称:monarch,代码行数:26,代码来源:JCAManagedConnection.java

示例5: cleanupTask

import java.util.Iterator; //导入方法依赖的package包/类
@Override
public void cleanupTask() {
    // Remove tombstones that are older than the tombstone deletion
    // threshold.  If a value is deleted and the tombstone has been 
    // cleaned up before the cluster is fully synchronized, then there
    // is a chance that deleted values could be resurrected
    Iterator<Entry<K, List<Versioned<V>>>> iter = map.entrySet().iterator();
    while (iter.hasNext()) {
        Entry<K, List<Versioned<V>>> e = iter.next();
        List<Versioned<V>> items = e.getValue();

        synchronized (items) {
            if (StoreUtils.canDelete(items, tombstoneDeletion))
                iter.remove();
        }
    }
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:18,代码来源:InMemoryStorageEngine.java

示例6: remove

import java.util.Iterator; //导入方法依赖的package包/类
@Override
public int remove(@Nullable Object key, int occurrences) {
  checkNonnegative(occurrences, "occurrences");
  if (occurrences == 0) {
    return count(key);
  }
  Collection<V> collection = unfiltered.asMap().get(key);
  if (collection == null) {
    return 0;
  }
  @SuppressWarnings("unchecked") // key is equal to a K, if not a K itself
  K k = (K) key;
  int oldCount = 0;
  Iterator<V> itr = collection.iterator();
  while (itr.hasNext()) {
    V v = itr.next();
    if (satisfies(k, v)) {
      oldCount++;
      if (oldCount <= occurrences) {
        itr.remove();
      }
    }
  }
  return oldCount;
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:26,代码来源:FilteredEntryMultimap.java

示例7: compact

import java.util.Iterator; //导入方法依赖的package包/类
public void compact() {
    Collections.sort(regions);

    Iterator<Region> iter = regions.iterator();
    Region prev = null;
    while (iter.hasNext()) {
        Region curr = iter.next();
        if (prev == null) {
            prev = curr;
        } else {
            // check for chaining
            if (curr.getAddressStart() == (prev.getAddressStart() + prev.getLength())) {
                prev.incLength(curr.getLength());
                iter.remove();
            } else {
                prev = curr;
            }
        }
    }
}
 
开发者ID:trol73,项目名称:avr-bootloader,代码行数:21,代码来源:MemoryRegions.java

示例8: getURIs

import java.util.Iterator; //导入方法依赖的package包/类
/**
 * Get all URIs, which are associated with at least one cookie
 * of this cookie store.
 */
public List<URI> getURIs() {
    List<URI> uris = new ArrayList<>();

    lock.lock();
    try {
        Iterator<URI> it = uriIndex.keySet().iterator();
        while (it.hasNext()) {
            URI uri = it.next();
            List<HttpCookie> cookies = uriIndex.get(uri);
            if (cookies == null || cookies.size() == 0) {
                // no cookies list or an empty list associated with
                // this uri entry, delete it
                it.remove();
            }
        }
    } finally {
        uris.addAll(uriIndex.keySet());
        lock.unlock();
    }

    return uris;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:InMemoryCookieStore.java

示例9: cancelTimer

import java.util.Iterator; //导入方法依赖的package包/类
/**
 * @param event
 * @param npc
 * @param player
 * @return {@code true} if timer for the given event, npc, player were stopped, {@code false} otheriwse
 */
public boolean cancelTimer(T event, L2Npc npc, L2PcInstance player)
{
	final Set<TimerHolder<T>> timers = _timers.get(event);
	if ((timers == null) || timers.isEmpty())
	{
		return false;
	}
	
	final Iterator<TimerHolder<T>> holders = timers.iterator();
	while (holders.hasNext())
	{
		final TimerHolder<T> holder = holders.next();
		if (holder.isEqual(event, npc, player))
		{
			holders.remove();
			return holder.cancelTimer();
		}
	}
	return false;
}
 
开发者ID:rubenswagner,项目名称:L2J-Global,代码行数:27,代码来源:TimerExecutor.java

示例10: startMerge

import java.util.Iterator; //导入方法依赖的package包/类
public void startMerge(Set<T> inputs) {
  if (!closed) {
    numPending.incrementAndGet();
    List<T> toMergeInputs = new ArrayList<T>();
    Iterator<T> iter=inputs.iterator();
    for (int ctr = 0; iter.hasNext() && ctr < mergeFactor; ++ctr) {
      toMergeInputs.add(iter.next());
      iter.remove();
    }
    LOG.info(getName() + ": Starting merge with " + toMergeInputs.size() + 
             " segments, while ignoring " + inputs.size() + " segments");
    synchronized(pendingToBeMerged) {
      pendingToBeMerged.addLast(toMergeInputs);
      pendingToBeMerged.notifyAll();
    }
  }
}
 
开发者ID:intel-hpdd,项目名称:lustre-connector-for-hadoop,代码行数:18,代码来源:LustreFsMergeThread.java

示例11: processSections

import java.util.Iterator; //导入方法依赖的package包/类
private void processSections( String snapshot, Map<String, Map<String, String>> props ) {

        // remove sections that are marked for removal

        Iterator<Map.Entry<String, Map<String, String>>> it = props.entrySet().iterator();
        while (it.hasNext()) {
            Map.Entry<String, Map<String, String>> entry = it.next();
            String section = entry.getKey();

            if (isSectionSkipped(snapshot, section)) {
                it.remove();
                continue;
            }
        }
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:16,代码来源:SkipIniMatcher.java

示例12: getTickets

import java.util.Iterator; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Timed(name = "GET_TICKETS_TIMER")
@Metered(name = "GET_TICKETS_METER")
@Counted(name="GET_TICKETS_COUNTER", monotonic=true)
@Override
public Collection<Ticket> getTickets(final Predicate predicate) {
    final Collection<Ticket> c = new HashSet<>(this.ticketRegistry.getTickets());
    final Iterator<Ticket> it = c.iterator();
    while (it.hasNext()) {
        if (!predicate.evaluate(it.next())) {
            it.remove();
        }
    }
    return c;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:18,代码来源:CentralAuthenticationServiceImpl.java

示例13: filter

import java.util.Iterator; //导入方法依赖的package包/类
@Override
public void filter(Map<String, Term> terms) {
	Iterator<Entry<String, Term>> iter = terms.entrySet().iterator();
	while(iter.hasNext()) {
		Entry<String, Term> entry = iter.next();
		if(entry.getValue().getWord() == null 
				|| entry.getValue().getWord().length() <= 1) {
			iter.remove();
		}
	}
}
 
开发者ID:Donkey-Tao,项目名称:sentimental-analyzer,代码行数:12,代码来源:SingleWordTermFilter.java

示例14: landmineExplode

import java.util.Iterator; //导入方法依赖的package包/类
@EventHandler
public void landmineExplode(final PlayerMoveEvent event) {
    MatchPlayer player = this.getMatch().getPlayer(event.getPlayer());
    if(!MatchPlayers.canInteract(player)) return;

    Location to = event.getTo();
    Iterator<Entry<Location, PlayerId>> iterator = this.landmines.entrySet().iterator();

    while(iterator.hasNext()) {
        Map.Entry<Location, PlayerId> entry = iterator.next();
        Location landmine = entry.getKey();
        MatchPlayer placer = this.getMatch().getPlayer(entry.getValue());

        if(placer == null || !placer.isParticipating()) {
            iterator.remove();
            continue;
        }

        Competitor placerTeam = this.landmineTeams.get(landmine);
        if(placerTeam == player.getParty()) continue;

        if(to.distanceSquared(landmine) < GhostSquadron.LANDMINE_ACTIVATION_DISTANCE_SQ) {
            TNTPrimed tnt = (TNTPrimed) landmine.getWorld().spawnEntity(landmine.clone().add(0, 1, 0), EntityType.PRIMED_TNT);
            tnt.setFuseTicks(0);
            tnt.setYield(1);

            this.reveal(player.getBukkit());
            getMatch().callEvent(new ExplosionPrimeByEntityEvent(tnt, placer.getBukkit()));
            iterator.remove();
            this.landmineTeams.remove(landmine);
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:34,代码来源:GhostSquadronMatchModule.java

示例15: removeOrTrackCompletedContainersFromContext

import java.util.Iterator; //导入方法依赖的package包/类
@VisibleForTesting
@Private
public void removeOrTrackCompletedContainersFromContext(
    List<ContainerId> containerIds) throws IOException {
  Set<ContainerId> removedContainers = new HashSet<ContainerId>();

  pendingContainersToRemove.addAll(containerIds);
  Iterator<ContainerId> iter = pendingContainersToRemove.iterator();
  while (iter.hasNext()) {
    ContainerId containerId = iter.next();
    // remove the container only if the container is at DONE state
    Container nmContainer = context.getContainers().get(containerId);
    if (nmContainer == null) {
      iter.remove();
    } else if (nmContainer.getContainerState().equals(
      org.apache.hadoop.yarn.server.nodemanager.containermanager.container.ContainerState.DONE)) {
      context.getContainers().remove(containerId);
      removedContainers.add(containerId);
      iter.remove();
    }
  }

  if (!removedContainers.isEmpty()) {
    LOG.info("Removed completed containers from NM context: "
        + removedContainers);
  }
  pendingCompletedContainers.clear();
}
 
开发者ID:naver,项目名称:hadoop,代码行数:29,代码来源:NodeStatusUpdaterImpl.java


注:本文中的java.util.Iterator.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。