priority-queue

command module
v0.0.0-...-e688809 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2023 License: MIT Imports: 2 Imported by: 0

README

Priority Queue in Go

This Go program demonstrates the implementation of a priority queue using the package container/heap. The program initializes a priority queue and adds several tasks with different priorities. The tasks are then processed in priority order, with the highest priority task being processed first.

Usage

  1. Make sure you have Go installed on your system.

  2. Clone the repository:

$ git clone https://github.com/lucasgrvarela/priority-queue.git
  1. Navigate to the project directory:
$ cd priority-queue
  1. Run the program:
$ go run main.go
Length of the priority queue is: 3
Processing task with Priority: 3, ID: 0, Description: 'Do A'
Processing task with Priority: 2, ID: 2, Description: 'Do C'
Processing task with Priority: 1, ID: 1, Description: 'Do B'
Length of the priority queue is: 0

Note: The methods Len(), Less(), Swap(), Push() and Pop() are implemented to satisfy the heap.Interface

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL