CircleQueueGo

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

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

Go to latest
Published: Nov 10, 2022 License: GPL-3.0 Imports: 1 Imported by: 0

README

Circle Queue Go (CircleQueueGo)

The Circle Queue implementation in Go. The circle queue is a special version of a queue where the last element of the queue is connected to the first element of the queue forming a circle. The operations are performed based on FIFO (First In First Out) principle. It is also called 'Ring Buffer'.

Installation

$ go get github.com/BaseMax/CircleQueueGo

Usage

package main

import "fmt"

func main() {
	q := NewCircleQueue(5)

	fmt.Println(q)

	q.Enqueue(1)
	q.Enqueue(2)
	q.Enqueue(3)
	q.Enqueue(4)
	q.Enqueue(5)

	fmt.Println(q)

	fmt.Println(q.Dequeue())
	fmt.Println(q.Dequeue())
	fmt.Println(q.Dequeue())
	fmt.Println(q.Dequeue())
	fmt.Println(q.Dequeue())
	fmt.Println(q.Dequeue())
	fmt.Println(q.Dequeue())
	fmt.Println(q.Dequeue())
	fmt.Println(q.Dequeue())

	q.Enqueue(6)
	q.Enqueue(7)
	q.Enqueue(8)
	q.Enqueue(9)
	q.Enqueue(10)
	q.Enqueue(11)

	fmt.Println(q)
}

© Copyright 2022, Max Base

Documentation

Overview

* @Name: Circle Queue Go * @Author: Max Base * @Date: 2022-11-07 * @Repository: https://github.com/basemax/CircleQueueGo

Jump to

Keyboard shortcuts

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