Skip to content

yasushi-saito/fifo_queue

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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


About

Simple FIFO queue for golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages