本文整理汇总了Java中java.util.ArrayList.containsAll方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayList.containsAll方法的具体用法?Java ArrayList.containsAll怎么用?Java ArrayList.containsAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ArrayList
的用法示例。
在下文中一共展示了ArrayList.containsAll方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkTasksPresent
import java.util.ArrayList; //导入方法依赖的package包/类
private void checkTasksPresent(String url, boolean mustBePresent, String... ids) throws Exception
{
List<String> taskIds = Arrays.asList(ids);
JSONObject json = getDataFromRequest(url);
JSONArray result = json.getJSONArray("data");
assertNotNull(result);
ArrayList<String> resultIds = new ArrayList<String>(result.length());
for (int i=0; i<result.length(); i++)
{
JSONObject taskObject = result.getJSONObject(i);
String taskId = taskObject.getString("id");
resultIds.add(taskId);
if (mustBePresent == false && taskIds.contains(taskId))
{
fail("The results should not contain id: "+taskId);
}
}
if (mustBePresent && resultIds.containsAll(taskIds) == false)
{
fail("Not all task Ids were present!\nExpected: "+taskIds +"\nActual: "+resultIds);
}
}
示例2: getTokenCompleted
import java.util.ArrayList; //导入方法依赖的package包/类
void getTokenCompleted(LoginClient.Request request, Bundle result) {
if (getTokenClient != null) {
getTokenClient.setCompletedListener(null);
}
getTokenClient = null;
loginClient.notifyBackgroundProcessingStop();
if (result != null) {
ArrayList<String> currentPermissions =
result.getStringArrayList(NativeProtocol.EXTRA_PERMISSIONS);
Set<String> permissions = request.getPermissions();
if ((currentPermissions != null) &&
((permissions == null) || currentPermissions.containsAll(permissions))) {
// We got all the permissions we needed, so we can complete the auth now.
complete(request, result);
return;
}
// We didn't get all the permissions we wanted, so update the request with just the
// permissions we still need.
Set<String> newPermissions = new HashSet<String>();
for (String permission : permissions) {
if (!currentPermissions.contains(permission)) {
newPermissions.add(permission);
}
}
if (!newPermissions.isEmpty()) {
addLoggingExtra(
LoginLogger.EVENT_EXTRAS_NEW_PERMISSIONS,
TextUtils.join(",", newPermissions)
);
}
request.setPermissions(newPermissions);
}
loginClient.tryNextHandler();
}
示例3: visitProjection
import java.util.ArrayList; //导入方法依赖的package包/类
@Override
public String visitProjection(RelationalAlgebraParser.ProjectionContext ctx) {
String translation = "SELECT " + visit(ctx.attrlist()) + " FROM " + visit(ctx.expr());
/**
* CASCADE OF PROJECTIONS: PROJECT [...] (PROJECT [...] (...));
* => check if the attributes list of a projection contains
* in the outer projection's attributes list.
*/
// If its parent it's a projection as well...
if (ctx.getParent() instanceof RelationalAlgebraParser.ProjectionContext) {
RelationalAlgebraParser.ProjectionContext currentProjectAttrList = ctx;
RelationalAlgebraParser.ProjectionContext outerProjectAttrList =
(ProjectionContext) ctx.getParent();
ArrayList<String> currentProjectAttributes;
ArrayList<String> outerProjectAttributes;
String[] currentProjectAttrListSplitted = splitAttrList(currentProjectAttrList);
String[] outerProjectAttrListSplitted = splitAttrList(outerProjectAttrList);
currentProjectAttributes = new ArrayList<String>(
Arrays.asList(currentProjectAttrListSplitted));
outerProjectAttributes = new ArrayList<String>(Arrays.asList(outerProjectAttrListSplitted));
if (!currentProjectAttributes.containsAll(outerProjectAttributes)) {
appendError("The projection attributes list " + currentProjectAttributes
+ " does not contain its outer projection attributes list "
+ outerProjectAttributes);
}
// Return only the RELATION
return visit(ctx.expr());
}
return translation;
}
示例4: visitDivision
import java.util.ArrayList; //导入方法依赖的package包/类
/**
* https://users.dcc.uchile.cl/~cgutierr/cursos/BD/divisionSQL.pdf
*/
@Override
public String visitDivision(RelationalAlgebraParser.DivisionContext ctx) {
ArrayList<Attribute> leftRelationColumns = expressionSchema(ctx.expr(0));
ArrayList<Attribute> rightRelationColumns = expressionSchema(ctx.expr(1));
if (leftRelationColumns == null || rightRelationColumns == null) {
return "";
}
// Let R(r) / S(s), r must contain s strictly
if (leftRelationColumns.size() > rightRelationColumns.size()) {
if (leftRelationColumns.containsAll(rightRelationColumns)) {
String division = "";
String divisionSchema = listToString(expressionSchema(ctx));
String rightRelationSchema = listToString(rightRelationColumns);
String leftRelationName = visit(ctx.expr(0));
String rightRelationName = visit(ctx.expr(1));
division += "SELECT " + divisionSchema + "\n";
division += "FROM " + leftRelationName + " NATURAL JOIN " + rightRelationName + "\n";
division += "GROUP BY " + divisionSchema + "\n";
division += "HAVING COUNT(*) = (SELECT COUNT(*) FROM " + rightRelationName + ")";
return preppendSelectStarIfNeeded(ctx, division);
}
}
appendError("Division: incompatible schemas.");
return "";
}
示例5: getRegisterClassForRegister
import java.util.ArrayList; //导入方法依赖的package包/类
/**
* Find the register class that contains the
* specified physical register. If the register is not in a register
* class, return null. If the register is in multiple classes, and the
* classes have a superset-subset relationship and the same set of
* types, return the superclass. Otherwise return null.
* @param r
* @return
*/
public CodeGenRegisterClass getRegisterClassForRegister(Record r)
{
ArrayList<CodeGenRegisterClass> rcs = getRegisterClasses();
CodeGenRegisterClass foundRC = null;
for (int i = 0, e = rcs.size(); i != e; ++i)
{
CodeGenRegisterClass rc = registerClasses.get(i);
for (int ei = 0, ee = rc.elts.size(); ei != ee; ++ei)
{
if (r != rc.elts.get(ei))
continue;
// If a register's classes have different types, return null.
if (foundRC != null && !rc.getValueTypes().equals(foundRC.getValueTypes()))
return null;
// If this is the first class that contains the register,
// make a note of it and go on to the next class.
if (foundRC == null)
{
foundRC = rc;
break;
}
ArrayList<Record> elements = new ArrayList<>();
elements.addAll(rc.elts);
ArrayList<Record> foundElements = new ArrayList<>();
foundElements.addAll(foundRC.elts);
// Check to see if the previously found class that contains
// the register is a subclass of the current class. If so,
// prefer the superclass.
if(elements.containsAll(foundElements))
{
foundRC = rc;
break;
}
// Check to see if the previously found class that contains
// the register is a superclass of the current class. If so,
// prefer the superclass.
if (foundElements.containsAll(elements))
break;
// Multiple classes, and neither is a superclass of the other.
// Return null.
return null;
}
}
return foundRC;
}
示例6: nextJoin
import java.util.ArrayList; //导入方法依赖的package包/类
/**
*
* @param start
* @param joinVars
* @return
*/
protected int nextJoin(int start, ArrayList<String> joinVars) {
// Triples are joined on the joinVars
String joinArg = toArgumentList(joinVars);
// Projection arguments initially contain everything from the current resultSchema
String projectArgs = addToProjectArgs("", null, (start == 1 ? "t0" : resultName), resultSchema);
/*
* JOIN
*/
List<Triple> triples = opBGP.getPattern().getList();
Triple triple = triples.get(start);
ArrayList<String> tripleVars = getVarsOfTriple(triple);
// start with joining current result relation (t0 or previous join) with t(start)
String joinArguments = (start == 1 ? "t0" : resultName) + " BY " + joinArg + ", t" + start + " BY " + joinArg;
// add variables of t(start) that do not already exist in the current resultSchema to the projection arguments
projectArgs = addToProjectArgs(projectArgs, resultSchema, "t" + start, tripleVars);
// update resultSchema -> add additional variables that do not already exist in the current resultSchema
addToResultSchema(tripleVars);
/*
* Successive Triples which also result in a JOIN on the same variables can be added to this JOIN
*/
ArrayList<String> sharedVars;
int endIndex = start + 1;
while (endIndex < triples.size()) {
triple = triples.get(endIndex);
tripleVars = getVarsOfTriple(triple);
sharedVars = getSharedVars(resultSchema, tripleVars);
if (joinVars.containsAll(sharedVars) && sharedVars.containsAll(joinVars)) {
// joinVars and sharedVars contain the same elements (perhaps not in the same order) -> add Triple to this JOIN
joinArguments += ", t" + endIndex + " BY " + joinArg;
// add variables of the current triple that do not already exist in the current resultSchema to the projection arguments
projectArgs = addToProjectArgs(projectArgs, resultSchema, "t" + endIndex, tripleVars);
// update resultSchema -> add additional variables that do not already exist in the current resultSchema
addToResultSchema(tripleVars);
endIndex++;
}
// Triple can't be added to this JOIN -> END OF JOIN
else
break;
}
String join = resultName + " = JOIN " + joinArguments + " ;";
joinBlock += join + "\n";
/*
* PROJECTION -> drop duplicated entries generated by the JOIN statement
*/
String foreach = resultName + " = FOREACH " + resultName + " GENERATE " + projectArgs + " ;";
joinBlock += foreach + "\n";
return endIndex - 1;
}
示例7: generateUnion
import java.util.ArrayList; //导入方法依赖的package包/类
private String generateUnion() {
String union = "";
ArrayList<String> leftOpSchema = leftOp.getSchema();
ArrayList<String> rightOpSchema = rightOp.getSchema();
// schemas are exactly the same
if(leftOpSchema.equals(rightOpSchema)) {
union += resultName + " = UNION ";
union += leftOp.getResultName() + ", " + rightOp.getResultName();
resultSchema.addAll(leftOp.getSchema());
}
// schemas are the same but in different order
else if (leftOpSchema.size()==rightOpSchema.size() && leftOpSchema.containsAll(rightOpSchema)) {
union += "u1 = FOREACH " + rightOp.getResultName() + " GENERATE ";
union += leftOpSchema.get(0);
for (int i=1; i<leftOpSchema.size(); i++) {
union += ", " + leftOpSchema.get(i);
}
union += " ;\n";
union += resultName + " = UNION " + leftOp.getResultName() + ", u1";
resultSchema.addAll(leftOpSchema);
}
// different schemas
else {
leftOuterVars = new ArrayList<String>();
rightOuterVars = new ArrayList<String>();
sharedVars = getSharedVars();
leftOuterVars.addAll(leftOp.getSchema());
leftOuterVars.removeAll(sharedVars);
rightOuterVars.addAll(rightOp.getSchema());
rightOuterVars.removeAll(sharedVars);
String u1 = "u1 = FOREACH " + leftOp.getResultName() + " GENERATE ";
String u2 = "u2 = FOREACH " + rightOp.getResultName() + " GENERATE ";
boolean first = true;
for (int i=0; i<sharedVars.size(); i++) {
u1 += (first ? "": ", ") + sharedVars.get(i);
u2 += (first ? "": ", ") + sharedVars.get(i);
first = false;
}
for (int i=0; i<leftOuterVars.size(); i++) {
u1 += (first ? "": ", ") + leftOuterVars.get(i);
u2 += (first ? "": ", ") + "null AS " + leftOuterVars.get(i);
first = false;
}
for (int i=0; i<rightOuterVars.size(); i++) {
u1 += (first ? "": ", ") + "null AS " + rightOuterVars.get(i);
u2 += (first ? "": ", ") + rightOuterVars.get(i);
first = false;
}
union += u1 + " ;\n" + u2 + " ;\n";
union += resultName + " = UNION " + "u1, u2";
resultSchema.addAll(sharedVars);
resultSchema.addAll(leftOuterVars);
resultSchema.addAll(rightOuterVars);
varsWithNulls.addAll(leftOuterVars);
varsWithNulls.addAll(rightOuterVars);
}
union += " ;\n";
return union;
}
示例8: contentsMatchs
import java.util.ArrayList; //导入方法依赖的package包/类
/**
* returns true if these two sets refer to the same objects.<br>
* This isn't as simple as a equals, as one or both sets might not yet have been cached into objects.<br>
* We thus get the object names from both sets, and compare them instead.<br>
* <br>
* BEWARE: dont attempt touching stuff on objects that have the same name as this can cause confusion with whats touching what
* @param set
* @return
*/
public boolean contentsMatchs(SceneObjectSet set){
ArrayList<String> ourNames = this.getNames();
ArrayList<String> comparisonNames = set.getNames();
return ourNames.containsAll(comparisonNames);
}