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

Method subtractInterval

runcontainer.go:1526–1546  ·  view source on GitHub ↗
(del interval16)

Source from the content-addressed store, hash-verified

1524}
1525
1526func (iv interval16) subtractInterval(del interval16) (left []interval16, delcount int) {
1527 isect, isEmpty := intersectInterval16s(iv, del)
1528
1529 if isEmpty {
1530 return nil, 0
1531 }
1532 if del.isSuperSetOf(iv) {
1533 return nil, iv.runlen()
1534 }
1535
1536 switch {
1537 case isect.start > iv.start && isect.last() < iv.last():
1538 new0 := newInterval16Range(iv.start, isect.start-1)
1539 new1 := newInterval16Range(isect.last()+1, iv.last())
1540 return []interval16{new0, new1}, isect.runlen()
1541 case isect.start == iv.start:
1542 return []interval16{newInterval16Range(isect.last()+1, iv.last())}, isect.runlen()
1543 default:
1544 return []interval16{newInterval16Range(iv.start, isect.start-1)}, isect.runlen()
1545 }
1546}
1547
1548func (rc *runContainer16) isubtract(del interval16) {
1549 origiv := make([]interval16, len(rc.iv))

Callers 2

isubtractMethod · 0.80

Calls 5

runlenMethod · 0.95
lastMethod · 0.95
intersectInterval16sFunction · 0.85
newInterval16RangeFunction · 0.85
isSuperSetOfMethod · 0.80

Tested by 1