MCPcopy Create free account
hub / github.com/EdgeSecurityTeam/EHole / Pops

Method Pops

module/queue/queue.go:45–66  ·  view source on GitHub ↗

返回pop列表和实际长度

(num int)

Source from the content-addressed store, hash-verified

43
44//返回pop列表和实际长度
45func (q *Queue) Pops(num int) ([]interface{}, int) {
46 vals := make([]interface{}, num)
47 i := 0
48 q.l.Lock()
49 defer q.l.Unlock()
50 for {
51 if i >= num {
52 break
53 }
54 iter := q.data.Back()
55 if iter == nil {
56 return vals, i
57 }
58 q.data.Remove(iter)
59 vals[i] = iter.Value
60 i++
61 }
62 if i < num {
63 return vals[0:i], i
64 }
65 return vals, i
66}
67
68func (q *Queue) Remove(v *list.Element) (interface{}) {
69 q.l.Lock()

Callers

nothing calls this directly

Calls 1

RemoveMethod · 0.80

Tested by

no test coverage detected