(IBitSet set)
| 423 | } |
| 424 | |
| 425 | @Override |
| 426 | public boolean or(IBitSet set) { |
| 427 | if (this == set) { |
| 428 | return false; |
| 429 | } |
| 430 | if (!(set instanceof RegularBitSet other)) { |
| 431 | return super.or(set); |
| 432 | } |
| 433 | |
| 434 | int wordsInCommon = Math.min(wordsInUse, other.wordsInUse); |
| 435 | |
| 436 | boolean changed = false; |
| 437 | if (wordsInUse < other.wordsInUse) { |
| 438 | ensureCapacity(other.wordsInUse); |
| 439 | wordsInUse = other.wordsInUse; |
| 440 | changed = true; |
| 441 | } |
| 442 | |
| 443 | // Perform logical OR on words in common |
| 444 | for (int i = 0; i < wordsInCommon; i++) { |
| 445 | if (changed) { |
| 446 | // already know set changed, just perform logical OR |
| 447 | words[i] |= other.words[i]; |
| 448 | } else { |
| 449 | long oldWord = words[i]; |
| 450 | long newWord = oldWord | other.words[i]; |
| 451 | if (oldWord != newWord) { |
| 452 | words[i] = newWord; |
| 453 | changed = true; |
| 454 | } |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | // Copy any remaining words |
| 459 | if (wordsInCommon < other.wordsInUse) { |
| 460 | System.arraycopy(other.words, wordsInCommon, |
| 461 | words, wordsInCommon, |
| 462 | wordsInUse - wordsInCommon); |
| 463 | } |
| 464 | |
| 465 | // recalculateWordsInUse() is unnecessary |
| 466 | checkInvariants(); |
| 467 | return changed; |
| 468 | } |
| 469 | |
| 470 | @Override |
| 471 | public IBitSet orDiff(IBitSet set) { |
nothing calls this directly
no test coverage detected