yata gofmt

This commit is contained in:
Todd Gruben 2018-11-26 15:21:37 -06:00
parent ba0ad350a9
commit de1b9b4de2
2 changed files with 9 additions and 7 deletions

View file

@ -478,25 +478,25 @@ func (b *Bitmap) Xor(other *Bitmap) *Bitmap {
return output
}
func (b *Bitmap) Shift() (*Bitmap) {
func (b *Bitmap) Shift() *Bitmap {
output := NewBitmap()
iiter, _ := b.Containers.Iterator(0)
last:=false
lastKey:= uint64(0)
last := false
lastKey := uint64(0)
for iiter.Next() {
ki, ci := iiter.Value()
o, carry := shift(ci)
if last {
o.add(0)
}
if o.n>0{
if o.n > 0 {
output.Containers.Put(ki, o)
}
last = carry
lastKey=ki
lastKey = ki
}
if last { //handle the overflow
extra:= NewContainer()
extra := NewContainer()
extra.add(0)
output.Containers.Put(lastKey+1, extra)
}

4
row.go
View file

@ -153,10 +153,11 @@ func (r *Row) Difference(other *Row) *Row {
return &Row{segments: segments}
}
// Shift returns the bitwise shift of r by 1 bit.
func (r *Row) Shift() *Row {
var segments []rowSegment
for _,segment := range r.segments {
for _, segment := range r.segments {
segments = append(segments, *segment.Shift())
}
@ -336,6 +337,7 @@ func (s *rowSegment) Xor(other *rowSegment) *rowSegment {
n: data.Count(),
}
}
// Shift returns s shifted by 1 bit.
func (s *rowSegment) Shift() *rowSegment {
//TODO deal with overflow