github.com/tobgu/qframe@v0.4.0/internal/index/index.go (about) 1 package index 2 3 type Int []uint32 4 5 type Bool []bool 6 7 func NewBool(size int) Bool { 8 return make(Bool, size) 9 } 10 11 func NewAscending(size uint32) Int { 12 newIndex := make(Int, size) 13 for i := range newIndex { 14 newIndex[i] = uint32(i) 15 } 16 17 return newIndex 18 } 19 20 func (ix Int) Filter(bIx Bool) Int { 21 count := 0 22 for _, b := range bIx { 23 if b { 24 count++ 25 } 26 } 27 28 result := make(Int, 0, count) 29 for i, b := range bIx { 30 if b { 31 result = append(result, ix[i]) 32 } 33 } 34 35 return result 36 } 37 38 func (ix Int) ByteSize() int { 39 return 4 * cap(ix) 40 } 41 42 func (ix Int) Len() int { 43 return len(ix) 44 } 45 46 func (ix Int) Copy() Int { 47 newIndex := make(Int, len(ix)) 48 copy(newIndex, ix) 49 return newIndex 50 } 51 52 func (ix Bool) Len() int { 53 return len(ix) 54 }