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


Java Collection.retainAll方法代码示例

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


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

示例1: dataFlushed

import java.util.Collection; //导入方法依赖的package包/类
/**
 * This method is eventually called from the middle of BinaryAnalyser work, after it flushes some data from memory. The method
 * must check & store information that the data is NOT visible to IndexReaders yet
 */
private void dataFlushed(Index index) throws IOException, InterruptedException {
    Collection<String> names = new LinkedList<String>();
    // check using collected usages

    index.query(
            names,
            DocumentUtil.binaryNameConvertor(),
            DocumentUtil.declaredTypesFieldSelector(false, false),
            null,
            QueryUtil.createUsagesQuery("java.util.List", EnumSet.of(UsageType.TYPE_REFERENCE), Occur.SHOULD));
    names.retainAll(
            Arrays.asList(
            "usages.ClassAnnotations",
            "usages.ClassArrayAnnotations",
            "usages.MethodAnnotations",
            "usages.MethodArrayAnnotations",
            "usages.FieldAnnotations",
            "usages.FieldArrayAnnotations")
    );
    assertTrue(names.isEmpty());

    flushCount++;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:BinaryAnalyserTest.java

示例2: addBooleanGetGetters

import java.util.Collection; //导入方法依赖的package包/类
private void addBooleanGetGetters() {
    Collection<String> accessibleBooleanFieldsWithoutGetGetters = new HashSet<String>();
    accessibleBooleanFieldsWithoutGetGetters.addAll(booleanFields);
    accessibleBooleanFieldsWithoutGetGetters.retainAll(booleanIsGetters);
    accessibleBooleanFieldsWithoutGetGetters.removeAll(booleanGetGetters);

    for (String booleanField : accessibleBooleanFieldsWithoutGetGetters) {
        addBooleanGetGetter(booleanField);
    }
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:11,代码来源:MixInLegacyTypesClassLoader.java

示例3: visit

import java.util.Collection; //导入方法依赖的package包/类
public Object visit(RBDisjunction disjunction) {
	Collection oldVars = getVars();
	Collection intersection = null;
	for (int i = 0; i < disjunction.getNumSubexps(); i++) {
		Collection next = disjunction.getSubexp(i).getVariables();
		if (intersection==null)
			intersection = next;
		else
			intersection.retainAll(next);
	}
	if (intersection != null) {
		oldVars.addAll(intersection);
	}
	return null;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:16,代码来源:CollectVarsVisitor.java

示例4: retainAll

import java.util.Collection; //导入方法依赖的package包/类
public static <A,B> A[] retainAll(A[] a, B[] b) {
    if (a.length == 0) {
        return a;
    }
    if (b.length == 0) {
        return makeArray(a, 0);
    }
    Collection<A> setA = new HashSet<A>(Arrays.asList(a));
    Collection<B> setB = new HashSet<B>(Arrays.asList(b));
    setA.retainAll(setB);
    return setA.isEmpty() ? makeArray(a, 0)
                          : setA.toArray(makeArray(a, setA.size()));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CollectionUtils.java

示例5: ofRetainAll

import java.util.Collection; //导入方法依赖的package包/类
public static <T> Operator<T, Boolean> ofRetainAll() {
	return new BooleanOperator<T>() {
		@Override
		protected Boolean executeOperator(Collection<T> src, OperateCondition<T, Boolean> condition) {
			return src.retainAll(condition.getOtherCollectionr());
		}
	};
}
 
开发者ID:LightSun,项目名称:Visitor,代码行数:9,代码来源:Operators.java

示例6: set

import java.util.Collection; //导入方法依赖的package包/类
public void set(CommandContext args, final CommandSender sender, final boolean value) throws CommandException {
    final MutationMatchModule module = verify(sender);
    final Match match = module.getMatch();
    String action = args.getString(0);
    // Mutations that *will* be added or removed
    final Collection<Mutation> mutations = new HashSet<>();
    // Mutations that *are allowed* to be added or removed
    final Collection<Mutation> availableMutations = Sets.newHashSet(Mutation.values());

    final Collection<Mutation> queue = mutationQueue.mutations();
    if(value) availableMutations.removeAll(queue); else availableMutations.retainAll(queue);
    // Check if all mutations have been enabled/disabled
    if((queue.size() == Mutation.values().length && value) || (queue.isEmpty() && !value)) {
        throw newCommandException(sender, new TranslatableComponent(value ? "command.mutation.error.enabled" : "command.mutation.error.disabled"));
    }
    // Get which action the user wants to preform
    switch (action) {
        case "*": mutations.addAll(availableMutations); break;
        case "?": mutations.add(Iterables.get(availableMutations, RandomUtils.safeNextInt(match.getRandom(), availableMutations.size()))); break;
        default:
            Mutation query = StringUtils.bestFuzzyMatch(action, Sets.newHashSet(Mutation.values()), 0.9);
            if (query == null) {
                throw newCommandException(sender, new TranslatableComponent("command.mutation.error.find", action));
            } else {
                mutations.add(query);
            }
    }

    // Send the queued changes off to the api
    syncExecutor.callback(
        value ? mutationQueue.mergeAll(mutations)
              : mutationQueue.removeAll(mutations),
        result -> {
            audiences.get(sender).sendMessage(new Component(new TranslatableComponent(
                message(false, value, mutations.size() == 1),
                new ListComponent(Collections2.transform(mutations, Mutation.toComponent(ChatColor.AQUA)))
            ), ChatColor.WHITE));
        }
    );
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:41,代码来源:MutationCommands.java

示例7: mergeValues

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Merges previously collected values with a new collection of values,
 * storing the result in oldValues.
 * 
 * By default, the intersection of the two collections is retained.
 */
protected void mergeValues(
  StyleSheetNode styleSheet,
  Collection<E>  oldValues,
  Collection<E>  newValues
  )
{
  oldValues.retainAll(newValues);
}
 
开发者ID:apache,项目名称:myfaces-trinidad,代码行数:15,代码来源:StableNameUtils.java

示例8: filterSearchCollections

import java.util.Collection; //导入方法依赖的package包/类
private void filterSearchCollections(DefaultSearch search, Collection<String> collectionUuids)
{
	final Collection<String> existing = search.getCollectionUuids();
	if( existing == null )
	{
		search.setCollectionUuids(collectionUuids);
	}
	else
	{
		existing.retainAll(collectionUuids);
	}
}
 
开发者ID:equella,项目名称:Equella,代码行数:13,代码来源:TopicDisplaySection.java

示例9: getEntitiesWith

import java.util.Collection; //导入方法依赖的package包/类
@SafeVarargs
public final Collection<Entity> getEntitiesWith(Collection<Entity> dst, Class<? extends Component>... types)
{
	boolean flag = false;
	for(Class<? extends Component> componentType : this.components.keySet())
	{
		for(Class<? extends Component> type : types)
		{
			if (type.isAssignableFrom(componentType))
			{
				Map<Entity, Component> entityComponentMap = this.components.get(componentType);
				if (!flag)
				{
					dst.addAll(entityComponentMap.keySet());
					flag = true;
				}
				else
				{
					dst.retainAll(entityComponentMap.keySet());

					if (dst.isEmpty())
					{
						return dst;
					}
				}
			}
		}
	}
	return dst;
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:31,代码来源:EntityManager.java

示例10: retainAll

import java.util.Collection; //导入方法依赖的package包/类
@Override
public boolean retainAll(Collection<?> c) {
    final Collection<V> coll = getMapping();
    if (coll == null) {
        return false;
    }

    boolean result = coll.retainAll(c);
    if (coll.isEmpty()) {
        AbstractMultiValuedMap.this.remove(key);
    }
    return result;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:14,代码来源:AbstractMultiValuedMap.java

示例11: needsMerge

import java.util.Collection; //导入方法依赖的package包/类
private static Pair<Group,Group> needsMerge(AnnotationSet aset, Collection<String> inter) {
	for (Group g1 : aset.getGroups())
		for (Group g2 : aset.getGroups()) {
			if (g1 == g2)
				continue;
			inter.clear();
			inter.addAll(g1.getItemIds());
			inter.retainAll(g2.getItemIds());
			if (!inter.isEmpty())
				return new Pair<Group,Group>(g1, g2);
		}
	return null;
}
 
开发者ID:Bibliome,项目名称:bibliome-java-utils,代码行数:14,代码来源:BiotopesDiff2013.java

示例12: intersection

import java.util.Collection; //导入方法依赖的package包/类
protected static <T> Collection<T> intersection(Collection<T> a, Collection<T> b) {
	Collection<T> result = new ArrayList<T>(a);
	result.retainAll(b);
	return result;
}
 
开发者ID:Bibliome,项目名称:alvisnlp,代码行数:6,代码来源:AbstractEvaluator.java

示例13: retainAll

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Retains all the elements in the specified collection in this composite set,
 * removing all others.
 * <p>
 * This implementation calls <code>retainAll()</code> on each collection.
 *
 * @param coll  the collection to remove
 * @return true if the composite was modified
 * @throws UnsupportedOperationException if retainAll is unsupported
 */
public boolean retainAll(final Collection<?> coll) {
    boolean changed = false;
    for (final Collection<E> item : all) {
        changed |= item.retainAll(coll);
    }
    return changed;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:18,代码来源:CompositeSet.java

示例14: retainAll

import java.util.Collection; //导入方法依赖的package包/类
/**
 * Retains all the elements in the specified collection in this composite collection,
 * removing all others.
 * <p>
 * This implementation calls <code>retainAll()</code> on each collection.
 *
 * @param coll  the collection to remove
 * @return true if the collection was modified
 * @throws UnsupportedOperationException if retainAll is unsupported
 */
@Override
public boolean retainAll(final Collection<?> coll) {
    boolean changed = false;
    for (final Collection<E> item : all) {
        changed |= item.retainAll(coll);
    }
    return changed;
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:19,代码来源:CompositeCollection.java


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