Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Byte implementation

  • Loading branch information...
commit f618fd850f6af70bb57664411c82724cdf89c0a3 1 parent 4b5d326
@reinerp authored
Showing with 20 additions and 1 deletion.
  1. +20 −1 bitvector.go
View
21 bitvector.go
@@ -1,6 +1,24 @@
package bitvector
-const (
+type Bitvector []uint8
+
+func New(length, capacity int) Bitvector {
+ return make([]uint8, length, capacity)
+}
+
+func (b Bitvector) At(i int) bool {
+ return b[i] != 0
+}
+
+func (b Bitvector) Set(i int, val bool) {
+ if val {
+ b[i] = 1
+ } else {
+ b[i] = 0
+ }
+}
+
+/*const (
width = 8
shift = 3
mask = 0x7
@@ -45,3 +63,4 @@ func (b Bitvector) checkLength(i int) {
panic("bitvector index out of range")
}*/
}
+*/
Please sign in to comment.
Something went wrong with that request. Please try again.