Skip to content

Commit 721a5f3

Browse files
committed
Documenting also private bucket functions.
In particular that inserting the same fingerprint multiple times is allowed.
1 parent 3ecfc46 commit 721a5f3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

bucket.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
// fingerprint represents a single entry in a bucket.
99
type fingerprint uint16
1010

11+
// bucket keeps track of fingerprints hashing to the same index.
1112
type bucket [bucketSize]fingerprint
1213

1314
const (
@@ -17,6 +18,8 @@ const (
1718
maxFingerprint = (1 << fingerprintSizeBits) - 1
1819
)
1920

21+
// insert a fingerprint into a bucket. Returns true if there was enough space and insertion succeeded.
22+
// Note it allows inserting the same fingerprint multiple times.
2023
func (b *bucket) insert(fp fingerprint) bool {
2124
for i, tfp := range b {
2225
if tfp == nullFp {
@@ -27,6 +30,8 @@ func (b *bucket) insert(fp fingerprint) bool {
2730
return false
2831
}
2932

33+
// delete a fingerprint from a bucket.
34+
// Returns true if the fingerprint was present and successfully removed.
3035
func (b *bucket) delete(fp fingerprint) bool {
3136
for i, tfp := range b {
3237
if tfp == fp {
@@ -46,6 +51,7 @@ func (b *bucket) contains(needle fingerprint) bool {
4651
return false
4752
}
4853

54+
// reset deletes all fingerprints in the bucket.
4955
func (b *bucket) reset() {
5056
for i := range b {
5157
b[i] = nullFp

0 commit comments

Comments
 (0)