Skip to content

Commit

Permalink
Add queue
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Haardiek <sven@haardiek.de>
  • Loading branch information
shaardie committed Oct 2, 2019
1 parent 3bcb65f commit 92e6a4c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions queue.go
@@ -0,0 +1,19 @@
package datastructures

// Queue is a basic implementation of a queue.
//
// For more information the data structure take a look at
// https://en.wikipedia.org/wiki/Queue_(abstract_data_type)
type Queue struct {
dll *DoubleLinkedList
}

// Enqueue add and element to the queue.
func (q Queue) Enqueue(element interface{}) {
q.dll.Append(element)
}

// Dequeue get the last element from the queue and removes it.
func (q Queue) Dequeue() interface{} {
return q.dll.Pop(0)
}

0 comments on commit 92e6a4c

Please sign in to comment.