queue

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2020 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package queue provides implementation for Queue data structure https://en.wikipedia.org/wiki/Queue_(abstract_data_type)

Interface methods Enqueue,Dequeue, IsEmpty,Size are the ways to interact with stack data structure. The test file queue_test.go illustrates usage of these methods

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Interface

type Interface interface {
	// Enqueue element to the stack
	Enqueue(x interface{})

	// Dequeue element
	// If queue is empty, returns nil
	Dequeue() interface{}

	// IsEmpty returns true if queue is empty
	IsEmpty() bool

	// Length returns number of elements in the queue
	Length() int
}

Interface implemented by stack, LIFO

type Queue

type Queue struct {
	Metadata lib.Metadata
	// contains filtered or unexported fields
}

Implementation of queue.Interface

func NewQueue

func NewQueue() *Queue

func (*Queue) Dequeue

func (q *Queue) Dequeue() interface{}

func (*Queue) Enqueue

func (q *Queue) Enqueue(elem interface{})

func (*Queue) IsEmpty

func (q *Queue) IsEmpty() bool

func (*Queue) Length

func (st *Queue) Length() int

Jump to

Keyboard shortcuts

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