Package list golang-gopkg-eapache-queue.v1 / 4a3e001
Access count directly rather than through a function Trivial simplification, though I suspect it won't have any practical impact since the compiler should have inlined the old way anyways. Evan Huus 7 years ago
1 changed file(s) with 3 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
5353 // Peek returns the element at the head of the queue. This call panics
5454 // if the queue is empty.
5555 func (q *Queue) Peek() interface{} {
56 if q.Length() <= 0 {
56 if q.count <= 0 {
5757 panic("queue: empty queue")
5858 }
5959 return q.buf[q.head]
6262 // Get returns the element at index i in the queue. If the index is
6363 // invalid, the call will panic.
6464 func (q *Queue) Get(i int) interface{} {
65 if i >= q.Length() || i < 0 {
65 if i >= q.count || i < 0 {
6666 panic("queue: index out of range")
6767 }
6868 return q.buf[(q.head+i)%len(q.buf)]
7171 // Remove removes the element from the front of the queue. If you actually
7272 // want the element, call Peek first. This call panics if the queue is empty.
7373 func (q *Queue) Remove() {
74 if q.Length() <= 0 {
74 if q.count <= 0 {
7575 panic("queue: empty queue")
7676 }
7777 q.buf[q.head] = nil