1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-10-18 04:03:01 +08:00

add more docs on hamt

License: MIT
Signed-off-by: Jeromy <why@ipfs.io>
This commit is contained in:
Jeromy
2016-11-17 13:39:37 -08:00
committed by Jeromy
parent c8af993a8c
commit 8d4791c9bb
2 changed files with 27 additions and 0 deletions

View File

@ -4,6 +4,7 @@ import (
"math/big"
)
// hashBits is a helper that allows the reading of the 'next n bits' as an integer.
type hashBits struct {
b []byte
consumed int
@ -13,6 +14,7 @@ func mkmask(n int) byte {
return (1 << uint(n)) - 1
}
// Next returns the next 'i' bits of the hashBits value as an integer
func (hb *hashBits) Next(i int) int {
curbi := hb.consumed / 8
leftb := 8 - (hb.consumed % 8)