rename conversion funcs to prepare for rle

also support rle in clone()
This commit is contained in:
Matt Jaffee 2017-05-17 16:18:56 -05:00
parent e80812cb0a
commit 98c8fd1ded

View file

@ -1086,7 +1086,7 @@ func (c *container) arrayAdd(v uint32) bool {
// Convert to a bitmap container if too many values are in an array container.
if c.n >= ArrayMaxSize {
c.convertToBitmap()
c.arrayToBitmap()
return c.bitmapAdd(v)
}
@ -1223,7 +1223,7 @@ func (c *container) bitmapRemove(v uint32) bool {
// Convert to array if we go below the threshold.
if c.n == ArrayMaxSize {
c.convertToArray()
c.bitmapToArray()
}
return true
}
@ -1297,7 +1297,7 @@ func (c *container) runMax() uint32 {
}
// convertToArray converts the values in the bitmap to array values.
func (c *container) convertToArray() {
func (c *container) bitmapToArray() {
c.array = make([]uint32, 0, c.n)
for i, bitmap := range c.bitmap {
for bitmap != 0 {
@ -1311,7 +1311,7 @@ func (c *container) convertToArray() {
}
// convertToBitmap converts the values in array to bitmap values.
func (c *container) convertToBitmap() {
func (c *container) arrayToBitmap() {
c.bitmap = make([]uint64, bitmapN)
for _, v := range c.array {
c.bitmap[int(v)/64] |= (uint64(1) << uint(v%64))
@ -1334,6 +1334,11 @@ func (c *container) clone() *container {
copy(other.bitmap, c.bitmap)
}
if c.runs != nil {
other.runs = make([]interval16, len(c.runs))
copy(other.runs, c.runs)
}
return other
}