From 26ae6e0b1b598e4189ca5223649f35e35fb7578b Mon Sep 17 00:00:00 2001 From: Nikhil Garg Date: Sat, 1 Aug 2015 14:21:33 -0700 Subject: [PATCH] bitset: rename BitSet to Bitset --- bitset.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bitset.go b/bitset.go index 3d17513..754071f 100644 --- a/bitset.go +++ b/bitset.go @@ -3,7 +3,7 @@ package bitset const word = uint64(64) const logword = uint(6) -type BitSet struct { +type Bitset struct { length uint64 bits []uint64 } @@ -12,9 +12,9 @@ func getSize(length uint64) uint64 { return uint64((length + word - 1) / word) } -func New(length uint64) *BitSet { +func New(length uint64) *Bitset { size := getSize(length) - return &BitSet{ + return &Bitset{ length, make([]uint64, size), } @@ -26,31 +26,31 @@ func getIndex(pos uint64) (q uint64, r uint) { return } -func (b *BitSet) Length() uint64 { +func (b *Bitset) Length() uint64 { return b.length } -func (b *BitSet) Get(pos uint64) bool { +func (b *Bitset) Get(pos uint64) bool { q, r := getIndex(pos) bit := (b.bits[q] >> r) & 1 return bit != 0 } -func (b *BitSet) Set(pos uint64) bool { +func (b *Bitset) Set(pos uint64) bool { current := b.Get(pos) q, r := getIndex(pos) b.bits[q] |= (1 << r) return current } -func (b *BitSet) Clear(pos uint64) bool { +func (b *Bitset) Clear(pos uint64) bool { current := b.Get(pos) q, r := getIndex(pos) b.bits[q] &= ^(1 << r) return current } -func (b *BitSet) Flip(pos uint64) bool { +func (b *Bitset) Flip(pos uint64) bool { current := b.Get(pos) q, r := getIndex(pos) b.bits[q] ^= (1 << r)