Codebase list golang-gopkg-eapache-queue.v1 / 4cf52fc
Add a comment, switch a conditional for readability Evan Huus 8 years ago
1 changed file(s) with 3 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
2626 return q.count
2727 }
2828
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
2931 func (q *Queue) resize() {
3032 newBuf := make([]interface{}, q.count*2)
3133
6466 // Get returns the element at index i in the queue. If the index is
6567 // invalid, the call will panic.
6668 func (q *Queue) Get(i int) interface{} {
67 if i >= q.count || i < 0 {
69 if i < 0 || i >= q.count {
6870 panic("queue: Get() called with index out of range")
6971 }
7072 return q.buf[(q.head+i)%len(q.buf)]