MCPcopy Create free account
hub / github.com/RoaringBitmap/roaring / AndNotRunContainer16

Method AndNotRunContainer16

runcontainer.go:1700–1764  ·  view source on GitHub ↗

compute rc minus b, and return the result as a new value (not inplace). port of run_container_andnot from CRoaring... https://github.com/RoaringBitmap/CRoaring/blob/master/src/containers/run.c#L435-L496

(b *runContainer16)

Source from the content-addressed store, hash-verified

1698// port of run_container_andnot from CRoaring...
1699// https://github.com/RoaringBitmap/CRoaring/blob/master/src/containers/run.c#L435-L496
1700func (rc *runContainer16) AndNotRunContainer16(b *runContainer16) *runContainer16 {
1701 if len(b.iv) == 0 || len(rc.iv) == 0 {
1702 return rc
1703 }
1704
1705 dst := newRunContainer16()
1706 apos := 0
1707 bpos := 0
1708
1709 a := rc
1710
1711 astart := a.iv[apos].start
1712 alast := a.iv[apos].last()
1713 bstart := b.iv[bpos].start
1714 blast := b.iv[bpos].last()
1715
1716 alen := len(a.iv)
1717 blen := len(b.iv)
1718
1719 for apos < alen && bpos < blen {
1720 switch {
1721 case alast < bstart:
1722 // output the first run
1723 dst.iv = append(dst.iv, newInterval16Range(astart, alast))
1724 apos++
1725 if apos < alen {
1726 astart = a.iv[apos].start
1727 alast = a.iv[apos].last()
1728 }
1729 case blast < astart:
1730 // exit the second run
1731 bpos++
1732 if bpos < blen {
1733 bstart = b.iv[bpos].start
1734 blast = b.iv[bpos].last()
1735 }
1736 default:
1737 // a: [ ]
1738 // b: [ ]
1739 // alast >= bstart
1740 // blast >= astart
1741 if astart < bstart {
1742 dst.iv = append(dst.iv, newInterval16Range(astart, bstart-1))
1743 }
1744 if alast > blast {
1745 astart = blast + 1
1746 } else {
1747 apos++
1748 if apos < alen {
1749 astart = a.iv[apos].start
1750 alast = a.iv[apos].last()
1751 }
1752 }
1753 }
1754 }
1755 if apos < alen {
1756 dst.iv = append(dst.iv, newInterval16Range(astart, alast))
1757 apos++

Callers 3

andNotRunContainer16Method · 0.95
iandNotRunContainer16Method · 0.95
NotMethod · 0.80

Calls 3

newRunContainer16Function · 0.85
newInterval16RangeFunction · 0.85
lastMethod · 0.80

Tested by

no test coverage detected