Queue

Stack and Queue

Queue FIFO package queue import "sync" type node struct { data interface{} next *node } type Queue struct { head *node tail *node count int lock *sync.Mutex } func NewQueue() *Queue { return &Queue{lock: &sync.Mutex{}} } func (q *Queue) Len() int { q.lock.Lock() defer q.lock.Unlock() return q.count } func (q *Queue) Push(data interface{}) { q.lock.Lock() defer q.lock.Unlock() ele := &node{data: data} if q.head == nil { q.head = ele q.tail = ele } else { q.