-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME
40 lines (26 loc) · 891 Bytes
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
fifo_queue.Queue is a simple FIFO queue. It supports pushing an item at
the end, and popping an item from the front. It is implemented as a
single-linked list of arrays of items.
INSTALLATION
go get github.com/yasushi-saito/fifo_queue
EXAMPLE:
import "github.com/yasushi-saito/fifo_queue"
q := fifo_queue.NewQueue()
q.PushBack("foo")
q.PushBack("bar")
item := q.PopFront().(string) // "foo"
item = q.PopFront().(string) // "bar"
TYPES
type Item interface{}
type Queue struct {
// contains filtered or unexported fields
}
func NewQueue() *Queue
Create a new empty FIFO queue
func (q *Queue) Len() int
Return the number of items in the queue
func (q *Queue) PopFront() Item
Remove the item at the head of the queue and return it.
REQUIRES: q.Len() > 0
func (q *Queue) PushBack(item Item)
Add an item to the end of the queue