MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / Push

Method Push

internal/utils/sets/set_fixed.go:30–45  ·  view source on GitHub ↗
(item any)

Source from the content-addressed store, hash-verified

28}
29
30func (this *FixedSet) Push(item any) {
31 this.locker.Lock()
32 _, ok := this.m[item]
33 if !ok {
34 // 是否已满
35 if len(this.keys) == this.maxSize {
36 var firstKey = this.keys[0]
37 this.keys = this.keys[1:]
38 delete(this.m, firstKey)
39 }
40
41 this.m[item] = zero.New()
42 this.keys = append(this.keys, item)
43 }
44 this.locker.Unlock()
45}
46
47func (this *FixedSet) Has(item any) bool {
48 this.locker.RLock()

Callers 3

TestNewFixedSetFunction · 0.45
TestFixedSet_ResetFunction · 0.45
BenchmarkFixedSet_HasFunction · 0.45

Calls 3

NewFunction · 0.92
LockMethod · 0.45
UnlockMethod · 0.45

Tested by 3

TestNewFixedSetFunction · 0.36
TestFixedSet_ResetFunction · 0.36
BenchmarkFixedSet_HasFunction · 0.36