Peek returns the head element. It panics if the queue is empty.
()
| 44 | |
| 45 | // Peek returns the head element. It panics if the queue is empty. |
| 46 | func (q *Queue[T]) Peek() T { |
| 47 | if q.count <= 0 { |
| 48 | panic("queue: Peek() called on empty queue") |
| 49 | } |
| 50 | return q.buf[q.head] |
| 51 | } |
| 52 | |
| 53 | // Remove pops and returns the head element. It panics if the queue is empty. |
| 54 | func (q *Queue[T]) Remove() T { |
no outgoing calls