Compare commits
3 Commits
docs/contr
...
f0c9fb9acf
| Author | SHA1 | Date | |
|---|---|---|---|
|
f0c9fb9acf
|
|||
|
f35583e079
|
|||
|
ce41d4fba2
|
@@ -114,6 +114,9 @@ linters:
|
|||||||
# Reports uses of functions with replacement inside the testing package.
|
# Reports uses of functions with replacement inside the testing package.
|
||||||
- usetesting
|
- usetesting
|
||||||
|
|
||||||
|
# Reports mixed receiver types in structs/interfaces.
|
||||||
|
- recvcheck
|
||||||
|
|
||||||
settings:
|
settings:
|
||||||
revive:
|
revive:
|
||||||
rules:
|
rules:
|
||||||
@@ -198,7 +201,7 @@ linters:
|
|||||||
|
|
||||||
# warns when initialism, variable or package naming conventions are not followed.
|
# warns when initialism, variable or package naming conventions are not followed.
|
||||||
- name: var-naming
|
- name: var-naming
|
||||||
|
|
||||||
misspell:
|
misspell:
|
||||||
# Correct spellings using locale preferences for US or UK.
|
# Correct spellings using locale preferences for US or UK.
|
||||||
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
# Setting locale to US will correct the British spelling of 'colour' to 'color'.
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ type subtable[K, V any] struct {
|
|||||||
|
|
||||||
// location determines where in the subtable a certain key would be placed. If
|
// location determines where in the subtable a certain key would be placed. If
|
||||||
// the capacity is 0, this will panic.
|
// the capacity is 0, this will panic.
|
||||||
func (t subtable[K, V]) location(key K) uint64 {
|
func (t *subtable[K, V]) location(key K) uint64 {
|
||||||
return t.hash(key) % t.capacity
|
return t.hash(key) % t.capacity
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t subtable[K, V]) get(key K) (value V, found bool) {
|
func (t *subtable[K, V]) get(key K) (value V, found bool) {
|
||||||
if t.capacity == 0 {
|
if t.capacity == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ func (t *subtable[K, V]) resize(capacity uint64) {
|
|||||||
t.size = 0
|
t.size = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t subtable[K, V]) update(key K, value V) (updated bool) {
|
func (t *subtable[K, V]) update(key K, value V) (updated bool) {
|
||||||
if t.capacity == 0 {
|
if t.capacity == 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
6
table.go
6
table.go
@@ -97,7 +97,7 @@ func (t *Table[K, V]) shrink() error {
|
|||||||
|
|
||||||
// Get fetches the value for a key in the [Table]. Matches the comma-ok pattern
|
// Get fetches the value for a key in the [Table]. Matches the comma-ok pattern
|
||||||
// of a builtin map; see [Table.Find] for plain indexing.
|
// of a builtin map; see [Table.Find] for plain indexing.
|
||||||
func (t Table[K, V]) Get(key K) (value V, ok bool) {
|
func (t *Table[K, V]) Get(key K) (value V, ok bool) {
|
||||||
if item, ok := t.tableA.get(key); ok {
|
if item, ok := t.tableA.get(key); ok {
|
||||||
return item, true
|
return item, true
|
||||||
}
|
}
|
||||||
@@ -111,13 +111,13 @@ func (t Table[K, V]) Get(key K) (value V, ok bool) {
|
|||||||
|
|
||||||
// Find fetches the value of a key. Matches direct indexing of a builtin map;
|
// Find fetches the value of a key. Matches direct indexing of a builtin map;
|
||||||
// see [Table.Get] for a comma-ok pattern.
|
// see [Table.Get] for a comma-ok pattern.
|
||||||
func (t Table[K, V]) Find(key K) (value V) {
|
func (t *Table[K, V]) Find(key K) (value V) {
|
||||||
value, _ = t.Get(key)
|
value, _ = t.Get(key)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Has returns true if a key has a value in the table.
|
// Has returns true if a key has a value in the table.
|
||||||
func (t Table[K, V]) Has(key K) (exists bool) {
|
func (t *Table[K, V]) Has(key K) (exists bool) {
|
||||||
_, exists = t.Get(key)
|
_, exists = t.Get(key)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user