Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sven Haardiek <sven@haardiek.de>
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} |