-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.go
47 lines (35 loc) · 904 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
40
41
42
43
44
45
46
47
/*
* @Name: Priority Sorted Queue Go
* @Author: Max Base
* @Date: 2022-11-14
* @Repository: https://github.com/basemax/PrioritySortedQueueGo
*/
package main
import "fmt"
func main() {
// Create a queue of capacity 5
queue := NewPriorityQueue(10)
// Inserting items to the queue
queue.Enqueue("A", 1)
queue.Enqueue("B", 20)
queue.Enqueue("C", 3)
queue.Enqueue("D", 4)
queue.Enqueue("E", 5)
// Print the queue
fmt.Println(queue.ToString())
// Dequeue two item
fmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
// Print the queue
fmt.Println(queue.ToString())
// Peek at the front of the queue
fmt.Println(queue.Peek())
// Print the queue
fmt.Println(queue.ToString())
// Print the size of the queue
fmt.Println(queue.Size())
// Clear the queue
queue.Clear()
// Print the queue
fmt.Println(queue.ToString())
}