MCPcopy Create free account
hub / github.com/GateNLP/gate-core / intersection

Method intersection

src/main/java/gate/relations/RelationSet.java:390–417  ·  view source on GitHub ↗

Calculates the intersection of a set of lists containing relation IDs @param indexLists the list to be intersected. @return the list of relations contained in all the supplied index lists.

(BitSet... indexLists)

Source from the content-addressed store, hash-verified

388 * lists.
389 */
390 protected Collection<Relation> intersection(BitSet... indexLists) {
391
392 Set<Relation> res = new HashSet<Relation>();
393
394 BitSet relIds = new BitSet(maxID + 1);
395 relIds.set(0, maxID + 1);
396
397 boolean found = false;
398
399 for(BitSet aList : indexLists) {
400 if(aList != null) {
401 found = true;
402 relIds.and(aList);
403
404 // if there is no intersection then return the empty list
405 if(relIds.isEmpty()) return res;
406 }
407 }
408
409 if(!found) return res;
410
411 for(int relIdx = 0; relIdx < (maxID + 1); relIdx++) {
412 if(relIds.get(relIdx)) {
413 res.add(indexById.get(relIdx));
414 }
415 }
416 return res;
417 }
418
419 /*
420 * (non-Javadoc)

Callers 1

getRelationsMethod · 0.95

Calls 4

getMethod · 0.65
addMethod · 0.65
setMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected