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

Method resize

queue.go:34–47  ·  view source on GitHub ↗

resizes the queue to fit exactly twice its current contents this can result in shrinking if the queue is less than half-full

()

Source from the content-addressed store, hash-verified

32// resizes the queue to fit exactly twice its current contents
33// this can result in shrinking if the queue is less than half-full
34func (q *Queue) resize() {
35 newBuf := make([]interface{}, q.count<<1)
36
37 if q.tail > q.head {
38 copy(newBuf, q.buf[q.head:q.tail])
39 } else {
40 n := copy(newBuf, q.buf[q.head:])
41 copy(newBuf[n:], q.buf[:q.tail])
42 }
43
44 q.head = 0
45 q.tail = q.count
46 q.buf = newBuf
47}
48
49// Add puts an element on the end of the queue.
50func (q *Queue) Add(elem interface{}) {

Callers 2

AddMethod · 0.95
RemoveMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected