Add a comment, switch a conditional for readability
Evan Huus
8 years ago
26 | 26 | return q.count |
27 | 27 | } |
28 | 28 | |
29 | // resizes the queue to fit exactly twice its current contents | |
30 | // this can result in shrinking if the queue is less than half-full | |
29 | 31 | func (q *Queue) resize() { |
30 | 32 | newBuf := make([]interface{}, q.count*2) |
31 | 33 | |
64 | 66 | // Get returns the element at index i in the queue. If the index is |
65 | 67 | // invalid, the call will panic. |
66 | 68 | func (q *Queue) Get(i int) interface{} { |
67 | if i >= q.count || i < 0 { | |
69 | if i < 0 || i >= q.count { | |
68 | 70 | panic("queue: Get() called with index out of range") |
69 | 71 | } |
70 | 72 | return q.buf[(q.head+i)%len(q.buf)] |