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


Java Collection.remove方法代码示例

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


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

示例1: removeFromResultsWithUnionOrIntersection

import java.util.Collection; //导入方法依赖的package包/类
private void removeFromResultsWithUnionOrIntersection(Collection results,
    SelectResults intermediateResults, boolean isIntersection, Object value) {
  if (intermediateResults == null) {
    results.remove(value);
  } else {
    if (isIntersection) {
      int numOcc = ((SelectResults) results).occurrences(value);
      if (numOcc > 0) {
        results.remove(value);
        intermediateResults.add(value);
      }
    } else {
      results.remove(value);
    }
  }
}
 
开发者ID:ampool,项目名称:monarch,代码行数:17,代码来源:AbstractIndex.java

示例2: testRemovePropagatesToAsMap

import java.util.Collection; //导入方法依赖的package包/类
@MapFeature.Require(SUPPORTS_REMOVE)
@CollectionSize.Require(absent = ZERO)
public void testRemovePropagatesToAsMap() {
  List<Entry<K, V>> entries = Helpers.copyToList(multimap().entries());
  for (Entry<K, V> entry : entries) {
    resetContainer();

    K key = entry.getKey();
    V value = entry.getValue();
    Collection<V> collection = multimap().asMap().get(key);
    assertNotNull(collection);
    Collection<V> expectedCollection = Helpers.copyToList(collection);

    multimap().remove(key, value);
    expectedCollection.remove(value);

    assertEqualIgnoringOrder(expectedCollection, collection);
    assertEquals(!expectedCollection.isEmpty(), multimap().containsKey(key));
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:21,代码来源:MultimapRemoveEntryTester.java

示例3: testValueIterator

import java.util.Collection; //导入方法依赖的package包/类
@Test
public void testValueIterator() {
    RMap<Integer, Integer> map = redisson.getMap("simple");
    map.put(1, 0);
    map.put(3, 5);
    map.put(4, 6);
    map.put(7, 8);

    Collection<Integer> values = map.values();
    assertThat(values).containsOnly(0, 5, 6, 8);
    for (Iterator<Integer> iterator = map.values().iterator(); iterator.hasNext();) {
        Integer value = iterator.next();
        if (!values.remove(value)) {
            Assert.fail();
        }
    }

    assertThat(values.size()).isEqualTo(0);
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:20,代码来源:RedissonMapTest.java

示例4: removeMapping

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Removes a specific value from map.
 * <p>
 * The item is removed from the collection mapped to the specified key.
 * Other values attached to that key are unaffected.
 * <p>
 * If the last value for a key is removed, <code>null</code> will be returned
 * from a subsequent <code>get(key)</code>.
 *
 * @param key  the key to remove from
 * @param value the value to remove
 * @return {@code true} if the mapping was removed, {@code false} otherwise
 */
@Override
public boolean removeMapping(final Object key, final Object value) {
    final Collection<V> valuesForKey = getCollection(key);
    if (valuesForKey == null) {
        return false;
    }
    final boolean removed = valuesForKey.remove(value);
    if (removed == false) {
        return false;
    }
    if (valuesForKey.isEmpty()) {
        remove(key);
    }
    return true;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:29,代码来源:MultiValueMap.java

示例5: removeDependenciesByCNB

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Use this for removing more than one dependencies. It's faster then
 * iterating and using <code>removeDependency</code> for every entry.
 */
public void removeDependenciesByCNB(Collection<String> cnbsToDelete) {
    Element _confData = getConfData();
    Element moduleDependencies = findModuleDependencies(_confData);
    for (Element dep : XMLUtil.findSubElements(moduleDependencies)) {
        Element cnbEl = findElement(dep, ProjectXMLManager.CODE_NAME_BASE);
        String _cnb = XMLUtil.findText(cnbEl);
        if (cnbsToDelete.remove(_cnb)) {
            moduleDependencies.removeChild(dep);
        }
        if (cnbsToDelete.size() == 0) {
            break; // everything was deleted
        }
    }
    if (cnbsToDelete.size() != 0) {
        Util.err.log(ErrorManager.WARNING,
                "Some modules weren't deleted: " + cnbsToDelete); // NOI18N
    }
    project.putPrimaryConfigurationData(_confData);
    directDeps = null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ProjectXMLManager.java

示例6: findCorrectItemsOrderByAnswers

import java.util.Collection; //导入方法依赖的package包/类
public List<String> findCorrectItemsOrderByAnswers(List<String> currentAnswers, Collection<OrderingItem> items) {
    List<String> itemsIdOrder = Lists.newArrayList();

    for (int i = 0; i < currentAnswers.size(); i++) {
        String currentAnswer = currentAnswers.get(i);
        OrderingItem item = findItemWithAnswer(currentAnswer, items);
        String itemId = item.getId();
        itemsIdOrder.add(itemId);

        items.remove(item);
    }

    return itemsIdOrder;
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:15,代码来源:ItemsOrderByAnswersFinder.java

示例7: processPositionalParameters0

import java.util.Collection; //导入方法依赖的package包/类
private void processPositionalParameters0(Collection<Field> required, boolean validateOnly, Stack<String> args) throws Exception {
    int max = -1;
    for (Field positionalParam : positionalParametersFields) {
        Range indexRange = Range.parameterIndex(positionalParam);
        max = Math.max(max, indexRange.max);
        @SuppressWarnings("unchecked")
        Stack<String> argsCopy = reverse((Stack<String>) args.clone());
        if (!indexRange.isVariable) {
            for (int i = argsCopy.size() - 1; i > indexRange.max; i--) {
                argsCopy.removeElementAt(i);
            }
        }
        Collections.reverse(argsCopy);
        for (int i = 0; i < indexRange.min && !argsCopy.isEmpty(); i++) { argsCopy.pop(); }
        Range arity = Range.parameterArity(positionalParam);
        assertNoMissingParameters(positionalParam, arity.min, argsCopy);
        if (!validateOnly) {
            applyOption(positionalParam, Parameters.class, arity, false, argsCopy, null);
            required.remove(positionalParam);
        }
    }
    // remove processed args from the stack
    if (!validateOnly && !positionalParametersFields.isEmpty()) {
        int processedArgCount = Math.min(args.size(), max < Integer.MAX_VALUE ? max + 1 : Integer.MAX_VALUE);
        for (int i = 0; i < processedArgCount; i++) { args.pop(); }
    }
}
 
开发者ID:alisianoi,项目名称:lyra2-java,代码行数:28,代码来源:CommandLine.java

示例8: picocliCommandLine

import java.util.Collection; //导入方法依赖的package包/类
@Bean
CommandLine picocliCommandLine(ApplicationContext applicationContext) {
    Collection<Object> commands = applicationContext.getBeansWithAnnotation(Command.class).values();
    Object main = getMainCommand(commands);
    commands.remove(main);

    CommandLine cli = new CommandLine(main);
    registerCommands(cli, commands);

    applicationContext.getBeansOfType(PicocliConfigurer.class).values().forEach(c -> c.configure(cli));
    return cli;
}
 
开发者ID:kakawait,项目名称:picocli-spring-boot-starter,代码行数:13,代码来源:PicocliAutoConfiguration.java

示例9: testSkip_structurallyModifiedSkipSome

import java.util.Collection; //导入方法依赖的package包/类
public void testSkip_structurallyModifiedSkipSome() throws Exception {
  Collection<String> set = newLinkedHashSet(asList("a", "b", "c"));
  Iterable<String> tail = skip(set, 1);
  set.remove("b");
  set.addAll(newArrayList("A", "B", "C"));
  assertThat(tail).containsExactly("c", "A", "B", "C").inOrder();
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:IterablesTest.java

示例10: check

import java.util.Collection; //导入方法依赖的package包/类
@Override
public void check(Certificate cert,
                  Collection<String> unresolvedCritExts)
        throws CertPathValidatorException {
    X509Certificate currCert = (X509Certificate)cert;
    // check that this is an EE cert
    if (currCert.getBasicConstraints() == -1) {
        if (unresolvedCritExts != null &&
                !unresolvedCritExts.isEmpty()) {
            unresolvedCritExts.remove("1.2.3.4");
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:EndEntityExtensionCheck.java

示例11: shutdownAllContainers

import java.util.Collection; //导入方法依赖的package包/类
private void shutdownAllContainers() {
    shuttingDown = true;

    restartService.close();

    // Close all CSS modules first.
    ConfigSystemService configSystem = getOSGiService(ConfigSystemService.class);
    if (configSystem != null) {
        configSystem.closeAllConfigModules();
    }

    LOG.info("Shutting down all blueprint containers...");

    Collection<Bundle> containerBundles = new HashSet<>(Arrays.asList(bundleContext.getBundles()));
    while (!containerBundles.isEmpty()) {
        // For each iteration of getBundlesToDestroy, as containers are destroyed, other containers become
        // eligible to be destroyed. We loop until we've destroyed them all.
        for (Bundle bundle : getBundlesToDestroy(containerBundles)) {
            containerBundles.remove(bundle);
            BlueprintContainer container = blueprintExtenderService.getContainer(bundle);
            if (container != null) {
                blueprintExtenderService.destroyContainer(bundle, container);
            }
        }
    }

    LOG.info("Shutdown of blueprint containers complete");
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:29,代码来源:BlueprintBundleTracker.java

示例12: dropOptions

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Drop an option and its descendents from a collection.
 *
 * @param o The {@code AbstractOption} to drop.
 * @param all The collection of options to drop from.
 */
private void dropOptions(AbstractOption o, Collection<AbstractOption> all) {
    all.remove(o);
    if (o instanceof OptionGroup) {
        OptionGroup og = (OptionGroup)o;
        for (Option op : og.getOptions()) {
            if (op instanceof AbstractOption) {
                dropOptions((AbstractOption)op, all);
            }
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:18,代码来源:Specification.java

示例13: removeDependency

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Remove a dependency of a main build script target on the target in the extension's script.
 * 
 * @param mainBuildTarget name of target in the main build script (see {@link org.netbeans.api.project.ant.AntBuildExtender#getExtensibleTargets})
 * @param extensionTarget name of target in the extension script
 */
public void removeDependency(String mainBuildTarget, String extensionTarget) {
    Collection<String> str = dependencies.get(mainBuildTarget);
    if (str != null) {
        if (str.remove(extensionTarget)) {
            updateProjectMetadata();
        }
    } else {
        //oh well, just ignore, nothing to update anyway..
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:AntBuildExtender.java

示例14: remove

import java.util.Collection; //导入方法依赖的package包/类
public void remove(VirtualNode vn, SubstrateNode sn) {
	Collection<VirtualNode> list = nodeMappings.get(sn);
	list.remove(vn);
	nodes.remove(vn);
	mappedVNodes--;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:7,代码来源:NodeLinkMapping.java

示例15: deleteRoomGroup

import java.util.Collection; //导入方法依赖的package包/类
/**
 * 
 * @param mapping
 * @param form
 * @param request
 * @param response
 * @return
 * @throws Exception 
 */
public ActionForward deleteRoomGroup(
		ActionMapping mapping,
		ActionForm form,
		HttpServletRequest request,
		HttpServletResponse response) throws Exception {
	RoomGroupEditForm roomGroupEditForm = (RoomGroupEditForm) form;
	Long id = new Long(roomGroupEditForm.getId());
	RoomGroupDAO rgdao = new RoomGroupDAO();
	
	org.hibernate.Session hibSession = rgdao.getSession();
	Transaction tx = null;
	try {
		tx = hibSession.beginTransaction();
		
		RoomGroup rg = rgdao.get(id, hibSession);
		
		if (rg != null) {
			
			sessionContext.checkPermission(rg, rg.isGlobal() ? Right.GlobalRoomGroupDelete : Right.DepartmenalRoomGroupDelete);
			
               ChangeLog.addChange(
                       hibSession, 
                       sessionContext, 
                       rg, 
                       ChangeLog.Source.ROOM_GROUP_EDIT, 
                       ChangeLog.Operation.DELETE, 
                       null, 
                       rg.getDepartment());

               Collection rooms = rg.getRooms();
			
			//remove roomGroup from room
			for (Iterator iter = rooms.iterator(); iter.hasNext();) {
				Location r = (Location) iter.next();
				Collection roomGroups = r.getRoomGroups();
				roomGroups.remove(rg);
				hibSession.saveOrUpdate(r);

			}
			
			for (RoomGroupPref p: (List<RoomGroupPref>)hibSession.createQuery("from RoomGroupPref p where p.roomGroup.uniqueId = :id")
					.setLong("id", id).list()) {
				p.getOwner().getPreferences().remove(p);
				hibSession.delete(p);
				hibSession.saveOrUpdate(p.getOwner());
			}

			
			hibSession.delete(rg);
		}
		
		tx.commit();
	} catch (Exception e) {
		Debug.error(e);
		try {
			if(tx!=null && tx.isActive())
				tx.rollback();
		}
		catch (Exception e1) { }
		throw e;
	}

	return mapping.findForward("showRoomGroupList");
}
 
开发者ID:Jenner4S,项目名称:unitimes,代码行数:74,代码来源:RoomGroupEditAction.java


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