Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

Priority Sorted Queue Go (PrioritySortedQueueGo)

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

Features

  • Sorted list
  • Support for custom priority
  • Support for custom data type

Installation

$ go get github.com/basemax/PrioritySortedQueueGo

Usage

package main
import"fmt"funcmain() {
// Create a queue of capacity 5queue:=NewPriorityQueue(10)
// Inserting items to the queuequeue.Enqueue("A", 1)
queue.Enqueue("B", 20)
queue.Enqueue("C", 3)
queue.Enqueue("D", 4)
queue.Enqueue("E", 5)
// Print the queuefmt.Println(queue.ToString())
// Dequeue two itemfmt.Println(queue.Dequeue())
fmt.Println(queue.Dequeue())
// Print the queuefmt.Println(queue.ToString())
// Peek at the front of the queuefmt.Println(queue.Peek())
// Print the queuefmt.Println(queue.ToString())
// Print the size of the queuefmt.Println(queue.Size())
// Clear the queuequeue.Clear()
// Print the queuefmt.Println(queue.ToString())
}

© Copyright 2022, Max Base

Releases

Packages

Used by

Contributors

Languages