Codebase list golang-gopkg-eapache-queue.v1 / 197b9db
Tweak godoc Evan Huus 9 years ago
1 changed file(s) with 4 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
1010
1111 const minQueueLen = 16
1212
13 // Queue represents a single instance of the queue data structure.
1314 type Queue struct {
1415 buf []interface{}
1516 head, tail, count int
1617 }
1718
18 // New constructs and returns a new Queue
19 // New constructs and returns a new Queue.
1920 func New() *Queue {
2021 return &Queue{buf: make([]interface{}, minQueueLen)}
2122 }
2223
23 // Length returns the number of elements currently stored in the queue
24 // Length returns the number of elements currently stored in the queue.
2425 func (q *Queue) Length() int {
2526 return q.count
2627 }
4041 q.buf = newBuf
4142 }
4243
43 // Add puts an element on the end of the queue
44 // Add puts an element on the end of the queue.
4445 func (q *Queue) Add(elem interface{}) {
4546 if q.count == len(q.buf) {
4647 q.resize()