MCPcopy Index your code
hub / github.com/eapache/queue / Get

Method Get

queue.go:74–84  ·  view source on GitHub ↗

Get returns the element at index i in the queue. If the index is invalid, the call will panic. This method accepts both positive and negative index values. Index 0 refers to the first element, and index -1 refers to the last.

(i int)

Source from the content-addressed store, hash-verified

72// negative index values. Index 0 refers to the first element, and
73// index -1 refers to the last.
74func (q *Queue) Get(i int) interface{} {
75 // If indexing backwards, convert to positive index.
76 if i < 0 {
77 i += q.count
78 }
79 if i < 0 || i >= q.count {
80 panic("queue: Get() called with index out of range")
81 }
82 // bitwise modulus
83 return q.buf[(q.head+i)&(len(q.buf)-1)]
84}
85
86// Remove removes and returns the element from the front of the queue. If the
87// queue is empty, the call will panic.

Callers 4

TestQueueGetFunction · 0.80
TestQueueGetNegativeFunction · 0.80
BenchmarkQueueGetFunction · 0.80

Calls

no outgoing calls

Tested by 4

TestQueueGetFunction · 0.64
TestQueueGetNegativeFunction · 0.64
BenchmarkQueueGetFunction · 0.64