本文整理汇总了Java中org.apache.commons.collections15.CollectionUtils.intersection方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.intersection方法的具体用法?Java CollectionUtils.intersection怎么用?Java CollectionUtils.intersection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections15.CollectionUtils
的用法示例。
在下文中一共展示了CollectionUtils.intersection方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addComposited
import org.apache.commons.collections15.CollectionUtils; //导入方法依赖的package包/类
/**
* Add an additional Map to the composite.
*
* @param map the Map to be added to the composite
* @throws IllegalArgumentException if there is a key collision and there is no
* MapMutator set to handle it.
*/
public synchronized void addComposited(Map<? extends K, ? extends V> map) throws IllegalArgumentException {
for (int i = composite.length - 1; i >= 0; --i) {
Collection<K> intersect = (Collection<K>) CollectionUtils.intersection(this.composite[i].keySet(), map.keySet());
if (intersect.size() != 0) {
if (this.mutator == null) {
throw new IllegalArgumentException("Key collision adding Map to CompositeMap");
} else {
this.mutator.resolveCollision(this, this.composite[i], map, intersect);
}
}
}
Map[] temp = new Map[this.composite.length + 1];
System.arraycopy(this.composite, 0, temp, 0, this.composite.length);
temp[temp.length - 1] = map;
this.composite = temp;
}
示例2: addComposited
import org.apache.commons.collections15.CollectionUtils; //导入方法依赖的package包/类
/**
* Add a Set to this composite
*
* @param c Must implement Set
* @throws IllegalArgumentException if c does not implement java.util.Set
* or if a SetMutator is set, but fails to resolve a collision
* @throws UnsupportedOperationException if there is no SetMutator set, or
* a CollectionMutator is set instead of a SetMutator
* @see org.apache.commons.collections15.collection.CompositeCollection.CollectionMutator
* @see SetMutator
*/
public synchronized void addComposited(Collection<? extends E> c) {
if (!(c instanceof Set)) {
throw new IllegalArgumentException("Collections added must implement java.util.Set");
}
for (Iterator i = this.getCollections().iterator(); i.hasNext();) {
Set set = (Set) i.next();
Collection intersects = CollectionUtils.intersection(set, c);
if (intersects.size() > 0) {
if (this.mutator == null) {
throw new UnsupportedOperationException("Collision adding composited collection with no SetMutator set");
} else if (!(this.mutator instanceof SetMutator)) {
throw new UnsupportedOperationException("Collision adding composited collection to a CompositeSet with a CollectionMutator instead of a SetMutator");
}
((SetMutator) this.mutator).resolveCollision(this, set, (Set) c, intersects);
if (CollectionUtils.intersection(set, c).size() > 0) {
throw new IllegalArgumentException("Attempt to add illegal entry unresolved by SetMutator.resolveCollision()");
}
}
}
super.addComposited((Collection<E>[]) new Collection[]{c});
}
示例3: checkWriteWriteConflict
import org.apache.commons.collections15.CollectionUtils; //导入方法依赖的package包/类
/**
* Calculate whether two Procedures have WRITE-WRITE conflicts
* @param proc0
* @param proc1
* @return
* @throws Exception
*/
protected Collection<Conflict> checkWriteWriteConflict(Procedure proc0, Procedure proc1) throws Exception {
ProcedureInfo pInfo0 = this.procedures.get(proc0);
assert(pInfo0 != null);
ProcedureInfo pInfo1 = this.procedures.get(proc1);
assert(pInfo1 != null);
Set<Conflict> conflicts = new HashSet<Conflict>();
// Write-Write Conflicts
// Any INSERT or DELETE is always a conflict
// For UPDATE, we will check whether their columns intersect
for (Statement stmt0 : pInfo0.writeQueries) {
if (this.ignoredStatements.contains(stmt0)) continue;
Collection<Table> tables0 = CatalogUtil.getReferencedTables(stmt0);
QueryType type0 = QueryType.get(stmt0.getQuerytype());
Collection<Column> cols0 = CatalogUtil.getReferencedColumns(stmt0);
boolean alwaysConflicting0 = this.alwaysWriteConflicting(stmt0, type0, tables0, cols0);
for (Statement stmt1 : pInfo1.writeQueries) {
if (this.ignoredStatements.contains(stmt1)) continue;
Collection<Table> tables1 = CatalogUtil.getReferencedTables(stmt1);
QueryType type1 = QueryType.get(stmt1.getQuerytype());
Collection<Column> cols1 = CatalogUtil.getReferencedColumns(stmt1);
boolean alwaysConflicting1 = this.alwaysWriteConflicting(stmt1, type1, tables1, cols1);
Collection<Table> intersectTables = CollectionUtils.intersection(tables0, tables1);
if (debug.val)
LOG.debug(String.format("WW %s <-> %s - Intersection Tables %s",
stmt0.fullName(), stmt1.fullName(), intersectTables));
if (intersectTables.isEmpty()) continue;
// If both queries are INSERTs, then this is always a conflict since
// there might be a global constraint...
if (type0 == QueryType.INSERT && type1 == QueryType.INSERT) {
// 2013-07-24
// This fails for John's INSERT INTO...SELECT queries.
// We need to decide whether we should have a new query type or not...
// assert(intersectTables.size() == 1) :
// String.format("There are %d intersection tables when we expected only 1: %s <-> %s",
// intersectTables.size(), stmt0.fullName(), stmt1.fullName());
alwaysConflicting1 = true;
}
Collection<Column> intersectColumns = CollectionUtils.intersection(cols0, cols1);
if (debug.val)
LOG.debug(String.format("WW %s <-> %s - Intersection Columns %s",
stmt0.fullName(), stmt1.fullName(), intersectColumns));
if (alwaysConflicting0 == false && alwaysConflicting1 == false && intersectColumns.isEmpty()) continue;
Conflict c = new Conflict(stmt0, stmt1, intersectTables, (alwaysConflicting0 || alwaysConflicting1));
conflicts.add(c);
} // FOR (proc1)
} // FOR (proc0)
return (conflicts);
}