-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.go
39 lines (31 loc) · 784 Bytes
/
example.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
* @Name: Priority Unsorted Queue Go
* @Author: Max Base
* @Date: 2022-11-12
* @Repository: https://github.com/basemax/PriorityUnsortedQueueGo
*/
package main
import "fmt"
// Main example
func main() {
// Create a new queue
queue := NewPriorityQueue(5)
// Enqueue some items
queue.Enqueue("A", 1)
queue.Enqueue("B", 2)
queue.Enqueue("C", 3)
queue.Enqueue("D", 4)
queue.Enqueue("E", 5)
fmt.Println(queue.ToString())
// Dequeue and print
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
queue.Enqueue("A", 10)
queue.Enqueue("B", 20)
queue.Enqueue("C", 3)
fmt.Println(queue.ToString())
}