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)
| 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) |
no test coverage detected