Tweak godoc
Evan Huus
9 years ago
10 | 10 | |
11 | 11 | const minQueueLen = 16 |
12 | 12 | |
13 | // Queue represents a single instance of the queue data structure. | |
13 | 14 | type Queue struct { |
14 | 15 | buf []interface{} |
15 | 16 | head, tail, count int |
16 | 17 | } |
17 | 18 | |
18 | // New constructs and returns a new Queue | |
19 | // New constructs and returns a new Queue. | |
19 | 20 | func New() *Queue { |
20 | 21 | return &Queue{buf: make([]interface{}, minQueueLen)} |
21 | 22 | } |
22 | 23 | |
23 | // Length returns the number of elements currently stored in the queue | |
24 | // Length returns the number of elements currently stored in the queue. | |
24 | 25 | func (q *Queue) Length() int { |
25 | 26 | return q.count |
26 | 27 | } |
40 | 41 | q.buf = newBuf |
41 | 42 | } |
42 | 43 | |
43 | // Add puts an element on the end of the queue | |
44 | // Add puts an element on the end of the queue. | |
44 | 45 | func (q *Queue) Add(elem interface{}) { |
45 | 46 | if q.count == len(q.buf) { |
46 | 47 | q.resize() |