本文整理汇总了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);
}
}
}
示例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));
}
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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(); }
}
}
示例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;
}
示例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();
}
示例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");
}
}
}
示例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");
}
示例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);
}
}
}
}
示例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..
}
}
示例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--;
}
示例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");
}