github.com/coyove/sdss@v0.0.0-20231129015646-c2ec58cca6a2/contrib/roaring/manyiterator.go (about)

     1  package roaring
     2  
     3  type manyIterable interface {
     4  	nextMany(hs uint32, buf []uint32) int
     5  	nextMany64(hs uint64, buf []uint64) int
     6  }
     7  
     8  func (si *shortIterator) nextMany(hs uint32, buf []uint32) int {
     9  	n := 0
    10  	l := si.loc
    11  	s := si.slice
    12  	for n < len(buf) && l < len(s) {
    13  		buf[n] = uint32(s[l]) | hs
    14  		l++
    15  		n++
    16  	}
    17  	si.loc = l
    18  	return n
    19  }
    20  
    21  func (si *shortIterator) nextMany64(hs uint64, buf []uint64) int {
    22  	n := 0
    23  	l := si.loc
    24  	s := si.slice
    25  	for n < len(buf) && l < len(s) {
    26  		buf[n] = uint64(s[l]) | hs
    27  		l++
    28  		n++
    29  	}
    30  	si.loc = l
    31  	return n
    32  }