MCPcopy Index your code
hub / github.com/0xAX/go-algorithms / Enqueue

Method Enqueue

queue/queue.go:50–62  ·  view source on GitHub ↗

Puts a given item into Queue

(item interface{})

Source from the content-addressed store, hash-verified

48
49// Puts a given item into Queue
50func (queue *Queue) Enqueue(item interface{}) {
51 if (queue.depth == 0) {
52 queue.current = &QueueItem{item: item, prev: nil}
53 queue.last = queue.current
54 queue.depth++
55 return
56 }
57
58 q := &QueueItem{item: item, prev: nil}
59 queue.last.prev = q
60 queue.last = q
61 queue.depth++
62}
63
64// Extracts first item from the Queue
65func (queue *Queue) Dequeue() interface{} {

Callers 1

TestQueueFunction · 0.95

Calls

no outgoing calls

Tested by 1

TestQueueFunction · 0.76