java.util.HashSet#containsAll ( )源码实例Demo

下面列出了java.util.HashSet#containsAll ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: gAnswer   文件: VariableFragment.java
public boolean containsAll(HashSet<Integer> s1) {
	Iterator<HashSet<Integer>> it = candTypes.iterator();
	while(it.hasNext()) {
		HashSet<Integer> s2 = it.next();
		if (s2.contains(magic_number)) {
			if (!Collections.disjoint(s1, s2)) {
				return true;
			}
		}
		else {
			if (s1.containsAll(s2) && s2.containsAll(s1)) {
				return true;
			}
		}
	}
	return false;
}
 
源代码2 项目: android   文件: RecentContentProvider.java
private void checkColumns(String[] projection) {
    String[] available = {
            RecentTable.COLUMN_ID,
            RecentTable.COLUMN_TYPE,
            RecentTable.COLUMN_TITLE,
            RecentTable.COLUMN_LINK,
            RecentTable.COLUMN_SEASON,
            RecentTable.COLUMN_EPISODE,
            RecentTable.COLUMN_IMAGE,
            RecentTable.COLUMN_NUM_SEASONS,
            RecentTable.COLUMN_NUM_EPISODES,
            RecentTable.COLUMN_RATING};
    if (projection != null) {
        HashSet<String> requestedColumns = new HashSet<String>(Arrays.asList(projection));
        HashSet<String> availableColumns = new HashSet<String>(Arrays.asList(available));
        // check if all columns which are requested are available
        if (!availableColumns.containsAll(requestedColumns)) {
            throw new IllegalArgumentException("Unknown columns in projection");
        }
    }
}
 
private void checkColumns(String[] projection) {
	String[] available = { TodoTable.COLUMN_CATEGORY,
			TodoTable.COLUMN_SUMMARY, TodoTable.COLUMN_DESCRIPTION,
			TodoTable.COLUMN_ID };
	if (projection != null) {
		HashSet<String> requestedColumns = new HashSet<String>(
				Arrays.asList(projection));
		HashSet<String> availableColumns = new HashSet<String>(
				Arrays.asList(available));
		// Check if all columns which are requested are available
		if (!availableColumns.containsAll(requestedColumns)) {
			throw new IllegalArgumentException(
					"Unknown columns in projection");
		}
	}
}
 
源代码4 项目: openchemlib-js   文件: Angle.java
/**
 * Checks if an angle is in a ring of given size. Will also check that
 * the atoms form an angle.
 *  @param mol The molecule that the angle is in.
 *  @param a1 Atom 1 of the angle.
 *  @param a2 Atom 2 of the angle.
 *  @param a3 Atom 3 of the angle.
 *  @param size The size of ring to check for.
 *  @return True if the angle is in the given size, false otherwise.
 */
public static boolean inRingOfSize(MMFFMolecule mol, int a1, int a2,
                                   int a3, int size) {
    RingCollection rings = mol.getRingSet();
    HashSet<Integer> angle = new HashSet<Integer>();
    angle.add(a1);
    angle.add(a2);
    angle.add(a3);

    if (mol.getBond(a1, a2) >= 0 && mol.getBond(a2, a3) >= 0)
        for (int r=0; r<rings.getSize(); r++)
            if (rings.getRingSize(r) == size) {
                HashSet<Integer> ring = new HashSet<Integer>();

                for (int a : rings.getRingAtoms(r))
                    ring.add(a);

                if (ring.containsAll(angle))
                    return true;
            }
    return false;
}
 
private void checkColumns(String[] projection) {
	String[] available = { TodoTable.COLUMN_CATEGORY,
			TodoTable.COLUMN_SUMMARY, TodoTable.COLUMN_DESCRIPTION,
			TodoTable.COLUMN_ID };
	if (projection != null) {
		HashSet<String> requestedColumns = new HashSet<String>(
				Arrays.asList(projection));
		HashSet<String> availableColumns = new HashSet<String>(
				Arrays.asList(available));
		// Check if all columns which are requested are available
		if (!availableColumns.containsAll(requestedColumns)) {
			throw new IllegalArgumentException(
					"Unknown columns in projection");
		}
	}
}
 
@Override
public boolean isIncludedIn(SimpleColumnCombination a, SimpleColumnCombination b) {
    HashSet<List<Long>> setA = sets.get(Integer.valueOf(a.getTable())).get(a);
    HashSet<List<Long>> setB = sets.get(Integer.valueOf(b.getTable())).get(b);
    this.numChecks++;
    return setB.containsAll(setA);
}
 
源代码7 项目: workcraft   文件: SetUtils.java
public static <T> boolean isFirstSmaller(HashSet<T> set1, HashSet<T> set2, boolean equalWins) {
    if (set2.containsAll(set1)) {
        if (set2.size() > set1.size()) return true;
        return equalWins;
    }
    return false;
}
 
private void checkForInitialSet(int i, ConcurrentMap testMap, Map initialSet) {
  HashSet found = new HashSet(testMap.values());
  if(!found.containsAll(initialSet.values())) {
    HashSet missed = new HashSet(initialSet.values());
    missed.removeAll(found);
    fail("On run " + i + " did not find these elements of the initial set using the iterator " + missed);
  }
}
 
源代码9 项目: Document-Scanner   文件: TextProvider.java
private void checkColumns(String[] projection) {
    String[] available = {TextEntry.COLUMN_SUMMARY, TextEntry.COLUMN_DESCRIPTION,TextEntry._ID };

    if (projection != null) {
        HashSet<String> requestedColumns = new HashSet<String>(Arrays.asList(projection));
        HashSet<String> availableColumns = new HashSet<String>(Arrays.asList(available));
        // check if all columns which are requested are available
        if (!availableColumns.containsAll(requestedColumns)) {
            throw new IllegalArgumentException("Unknown columns in projection");
        }
    }
}
 
源代码10 项目: Popular-Movies-App   文件: MoviesProvider.java
private void checkColumns(String[] projection) {
    if (projection != null) {
        HashSet<String> availableColumns = new HashSet<>(Arrays.asList(
                MoviesContract.MovieEntry.getColumns()));
        HashSet<String> requestedColumns = new HashSet<>(Arrays.asList(projection));
        if (!availableColumns.containsAll(requestedColumns)) {
            throw new IllegalArgumentException("Unknown columns in projection.");
        }
    }
}
 
源代码11 项目: iBioSim   文件: DirectMatch.java
private boolean isMatch(DecomposedGraphNode specNode, DecomposedGraphNode libNode) throws GeneticGatesException {

		HashSet<DecomposedGraphNode> visited = new HashSet<>();
		Queue<EndNode> queue = new LinkedList<>();
		queue.add(new EndNode(specNode, libNode));

		while(!queue.isEmpty()) {
			EndNode node = queue.poll();

			if(node.libNode.getChildrenNodeList().size() == 0) {
				break;
			}
			else {
				for(int i = 0; i < node.libNode.getChildrenNodeList().size(); i++) {
					if(node.specNode.getChildrenNodeList().size() != node.libNode.getChildrenNodeList().size()) {
						return false;
					}

					for(int j = 0; j < node.specNode.getChildrenNodeList().size(); j++) {
						if(!visited.contains(node.specNode.getChildrenNodeList().get(j)) &&
								node.specNode.getChildInteractionType(node.specNode.getChildrenNodeList().get(j)) == node.libNode.getChildInteractionType(node.libNode.getChildrenNodeList().get(i))) {

							visited.add(node.specNode.getChildrenNodeList().get(j));
							queue.add(new EndNode(node.specNode.getChildrenNodeList().get(j), node.libNode.getChildrenNodeList().get(i)));
						}
					}
					if(!visited.containsAll(node.specNode.getChildrenNodeList())) {
						return false;
					}

				}
			}
		}
		return true;
	}
 
源代码12 项目: RegexStaticAnalysis   文件: NFAGraph.java
@Override
public boolean equals(Object o) {
	if (!super.equals(o)) {
		return false;
	}
	
	/* testing that the amount of parallel edges are equal */
	NFAGraph n = (NFAGraph) o;
	for (NFAEdge e : n.edgeSet()) {
		Set<NFAEdge> nEdges = super.getAllEdges(e.getSourceVertex(), e.getTargetVertex());
		for (NFAEdge nEdge : nEdges) {
			if (e.equals(nEdge) && e.getNumParallel() != nEdge.getNumParallel()) {
				return false;
			}
		}
		
	}
	
	if (initialState != null && !initialState.equals(n.getInitialState())) {
		return false;
	}
	
	HashSet<NFAVertexND> myAcceptingStates = new HashSet<NFAVertexND>(acceptingStates);
	HashSet<NFAVertexND> otherAcceptingStates = new HashSet<NFAVertexND>(n.getAcceptingStates());

	boolean condition1 = myAcceptingStates.size() == otherAcceptingStates.size();
	boolean condition2 = myAcceptingStates.containsAll(otherAcceptingStates);
	boolean condition3 = otherAcceptingStates.containsAll(myAcceptingStates);
	/* first condition might be redundant */
	return condition1 && condition2 && condition3 ;

}
 
源代码13 项目: soas   文件: OfflineNotesProvider.java
private void checkColumns(String[] projection) {
    String[] available = {OfflineNotesDataSource.COLUMN_PHOTO_ID,
            OfflineNotesDataSource.COLUMN_NOTE,
            OfflineNotesDataSource.COLUMN_ID};

    if (projection != null) {
        HashSet<String> requestedColumns = new HashSet<String>(Arrays.asList(projection));
        HashSet<String> availableColumns = new HashSet<String>(Arrays.asList(available));

        // Check if all columns which are requested are available.
        if (!availableColumns.containsAll(requestedColumns)) {
            throw new IllegalArgumentException("Unknown columns in projection");
        }
    }
}
 
源代码14 项目: openchemlib-js   文件: Torsion.java
/**
 * Checks and returns the minimum ring size that a torsion is
 * contained in. Only checks rings of size 4 and 5.
 *  @param mol The molecule that the atoms are in.
 *  @param a1 Atom 1.
 *  @param a2 Atom 2.
 *  @param a3 Atom 3.
 *  @param a4 Atom 4.
 */
public static int inRingOfSize(MMFFMolecule mol, int a1, int a2,
                               int a3, int a4) {

    // If any of the four atoms don't have bonds between them, then they
    // don't form a torsion angle and there fore this invalid torsion
    // cannot be in a ring.
    if (mol.getBond(a1, a2) == -1 || mol.getBond(a2, a3) == -1
            || mol.getBond(a3, a4) == -1)
        return 0;

    // If atom 4 is connected to atom 1, then the torsion loops back on to
    // itself and is in a ring of size 4.
    if (mol.getBond(a4, a1) >= 0)
        return 4;


    RingCollection rings = mol.getRingSet();
    HashSet<Integer> tor = new HashSet<Integer>();
    tor.add(a1);
    tor.add(a2);
    tor.add(a3);
    tor.add(a4);

    // Loop over all the molecule rings, for all rings of size 5 check if
    // the set of ring atoms contains the torsion angle atoms with a set
    // intersection. If true then the ring contains the torsion.
    for (int r=0; r<rings.getSize(); r++)
        if (rings.getRingSize(r) == 5) {
            HashSet<Integer> ring = new HashSet<Integer>();

            for (int a : rings.getRingAtoms(r))
                ring.add(a);

            if (ring.containsAll(tor))
                return 5;
        }

    return 0;
}
 
private void checkForInitialSet(int i, ConcurrentMap testMap, Map initialSet) {
  HashSet found = new HashSet(testMap.values());
  if(!found.containsAll(initialSet.values())) {
    HashSet missed = new HashSet(initialSet.values());
    missed.removeAll(found);
    fail("On run " + i + " did not find these elements of the initial set using the iterator " + missed);
  }
}
 
源代码16 项目: beast-mcmc   文件: TaxaOriginTrait.java
private HashMap<String,String> getIncomingJumpOrigins(FlexibleTree tree){
    HashMap<String,String> out = new HashMap<String, String>();

    FlexibleNode[] tips = getTipsOfInterest(tree);
    FlexibleNode mrca = findCommonAncestor(tree, tips);
    HashSet<FlexibleNode> taxaSet = new HashSet<FlexibleNode>(Arrays.asList(tips));
    HashSet<FlexibleNode> tipSet = getTipSet(tree, mrca);
    if(!taxaSet.containsAll(tipSet)){
        System.out.println("WARNING: mixed traits in a clade");
    }
    if(!mrca.getAttribute(attributeName).equals(traitName)){
        out.put(traitName,"Multiple");
        System.out.println("Multiple origin found.");
    } else {
        boolean sameTrait = true;
        FlexibleNode currentParent = mrca;
        while(sameTrait){
            currentParent = (FlexibleNode)tree.getParent(currentParent);
            if(currentParent==null){
                out.put(traitName,"root");
                break;
            } else {
                String parentTrait = (String)currentParent.getAttribute(attributeName);
                if(!parentTrait.equals(traitName)){
                    sameTrait = false;
                    out.put(traitName,parentTrait);
                }
            }
        }


    }
    return out;
}
 
源代码17 项目: bitseal   文件: DatabaseContentProvider.java
private void checkColumns(String[] projection, int uriType) 
{
   String[] available = getAvailable(uriType);

   if (projection != null)
   {
    HashSet<String> requestedColumns = new HashSet<String>(Arrays.asList(projection));
    HashSet<String> availableColumns = new HashSet<String>(Arrays.asList(available));
    // check if all columns which are requested are available
    if (!availableColumns.containsAll(requestedColumns)) 
    {
	    throw new IllegalArgumentException("Unknown columns in projection. Exception occurred in DatabaseContentProvider.checkColumns()");
    }
  }
}
 
源代码18 项目: WonderAdapter   文件: MinionContentProvider.java
/**
 * This method is invoked on the query process. It's responsible to verify if all the columns projected do exist in the database.
 * Should throw a IllegalArgumentException runtime error if failed
 * @param projection The array of fields to verify
 */
public void checkColumns(String[] projection) {
    String[] available = getAvailableColumns();
    if (projection != null) {
        HashSet<String> requestedColumns = new HashSet<String>(Arrays.asList(projection));
        HashSet<String> availableColumns = new HashSet<String>(Arrays.asList(available));
        // Check if all columns which are requested are available
        if (!availableColumns.containsAll(requestedColumns)) {
            throw new IllegalArgumentException(
                    "Unknown columns in projection");
        }
    }
}
 
源代码19 项目: spotbugs   文件: Ideas_2011_07_24.java
@NoWarning("GC_UNRELATED_TYPES")
static boolean test2(HashSet<Integer> s, LinkedList<Integer> lst) {
    return s.containsAll(lst) && lst.containsAll(s);
}
 
源代码20 项目: spotbugs   文件: Ideas_2011_07_24.java
@ExpectWarning("GC_UNRELATED_TYPES")
static boolean test4(HashSet<Integer> s, LinkedList<String> lst) {
    return s.containsAll(lst) && lst.containsAll(s);
}