File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change 88// fingerprint represents a single entry in a bucket.
99type fingerprint uint16
1010
11+ // bucket keeps track of fingerprints hashing to the same index.
1112type bucket [bucketSize ]fingerprint
1213
1314const (
@@ -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.
2023func (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.
3035func (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.
4955func (b * bucket ) reset () {
5056 for i := range b {
5157 b [i ] = nullFp
You can’t perform that action at this time.
0 commit comments