Or computes the union between two bitmaps and stores the result in the current bitmap
(x2 *Bitmap)
| 674 | |
| 675 | // Or computes the union between two bitmaps and stores the result in the current bitmap |
| 676 | func (rb *Bitmap) Or(x2 *Bitmap) { |
| 677 | pos1 := 0 |
| 678 | pos2 := 0 |
| 679 | length1 := rb.highlowcontainer.size() |
| 680 | length2 := x2.highlowcontainer.size() |
| 681 | main: |
| 682 | for (pos1 < length1) && (pos2 < length2) { |
| 683 | s1 := rb.highlowcontainer.getKeyAtIndex(pos1) |
| 684 | s2 := x2.highlowcontainer.getKeyAtIndex(pos2) |
| 685 | |
| 686 | for { |
| 687 | if s1 < s2 { |
| 688 | pos1++ |
| 689 | if pos1 == length1 { |
| 690 | break main |
| 691 | } |
| 692 | s1 = rb.highlowcontainer.getKeyAtIndex(pos1) |
| 693 | } else if s1 > s2 { |
| 694 | rb.highlowcontainer.insertNewKeyValueAt(pos1, s2, x2.highlowcontainer.getContainerAtIndex(pos2).Clone()) |
| 695 | pos1++ |
| 696 | length1++ |
| 697 | pos2++ |
| 698 | if pos2 == length2 { |
| 699 | break main |
| 700 | } |
| 701 | s2 = x2.highlowcontainer.getKeyAtIndex(pos2) |
| 702 | } else { |
| 703 | rb.highlowcontainer.getWritableContainerAtIndex(pos1).Or(x2.highlowcontainer.getContainerAtIndex(pos2)) |
| 704 | pos1++ |
| 705 | pos2++ |
| 706 | if (pos1 == length1) || (pos2 == length2) { |
| 707 | break main |
| 708 | } |
| 709 | s1 = rb.highlowcontainer.getKeyAtIndex(pos1) |
| 710 | s2 = x2.highlowcontainer.getKeyAtIndex(pos2) |
| 711 | } |
| 712 | } |
| 713 | } |
| 714 | if pos1 == length1 { |
| 715 | rb.highlowcontainer.appendCopyMany(x2.highlowcontainer, pos2, length2) |
| 716 | } |
| 717 | } |
| 718 | |
| 719 | // AndNot computes the difference between two bitmaps and stores the result in the current bitmap |
| 720 | func (rb *Bitmap) AndNot(x2 *Bitmap) { |