BaseMax/PrioritySortedQueueGo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a priority sorted queue written in Go (Golang).

  • Sorted list
  • Support for custom priority
  • Support for custom data type
$ go get .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())
}

© Copyright 2022, Max Base

About

This is a priority sorted queue written in Go (Golang).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages