datastructure

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayQueue

type ArrayQueue[T any] struct {
	// contains filtered or unexported fields
}

ArrayQueue implements queue with slice

func NewArrayQueue

func NewArrayQueue[T any](values ...T) *ArrayQueue[T]

NewArrayQueue return a empty ArrayQueue pointer

func (*ArrayQueue[T]) Back

func (q *ArrayQueue[T]) Back() T

Back return back value of queue

func (*ArrayQueue[T]) Clear

func (q *ArrayQueue[T]) Clear()

Clear the queue data

func (*ArrayQueue[T]) Contain

func (q *ArrayQueue[T]) Contain(value T) bool

Contain checks if the value is in queue or not

func (*ArrayQueue[T]) Data

func (q *ArrayQueue[T]) Data() []T

Data return queue data

func (*ArrayQueue[T]) DeQueue

func (q *ArrayQueue[T]) DeQueue() (*T, error)

DeQueue remove head element of queue and return it, if queue is empty, return nil and error

func (*ArrayQueue[T]) EnQueue

func (q *ArrayQueue[T]) EnQueue(value T)

EnQueue put element into queue

func (*ArrayQueue[T]) Front

func (q *ArrayQueue[T]) Front() T

Front return front value of queue

func (*ArrayQueue[T]) IsEmpty

func (q *ArrayQueue[T]) IsEmpty() bool

IsEmpty checks if queue is empty or not

func (*ArrayQueue[T]) Print

func (q *ArrayQueue[T]) Print()

Print queue data

func (*ArrayQueue[T]) Size

func (q *ArrayQueue[T]) Size() int

Size return length of queue data

type CircularQueue

type CircularQueue[T any] struct {
	// contains filtered or unexported fields
}

CircularQueue implements circular queue with slice, last index of CircularQueue don't contain value, so acturl capacity is size - 1

func NewCircularQueue

func NewCircularQueue[T any](size int) *CircularQueue[T]

NewCircularQueue return a empty CircularQueue pointer

func (*CircularQueue[T]) Back

func (q *CircularQueue[T]) Back() T

Back return back value of queue

func (*CircularQueue[T]) Clear

func (q *CircularQueue[T]) Clear()

Clear the queue data

func (*CircularQueue[T]) Contain

func (q *CircularQueue[T]) Contain(value T) bool

Contain checks if the value is in queue or not

func (*CircularQueue[T]) Data

func (q *CircularQueue[T]) Data() []T

Data return queue data

func (*CircularQueue[T]) DeQueue

func (q *CircularQueue[T]) DeQueue() (*T, error)

DeQueue remove head element of queue and return it, if queue is empty, return nil and error

func (*CircularQueue[T]) EnQueue

func (q *CircularQueue[T]) EnQueue(value T) error

EnQueue put element into queue

func (*CircularQueue[T]) Front

func (q *CircularQueue[T]) Front() T

Front return front value of queue

func (*CircularQueue[T]) IsEmpty

func (q *CircularQueue[T]) IsEmpty() bool

IsEmpty checks if queue is empty or not

func (*CircularQueue[T]) IsFull

func (q *CircularQueue[T]) IsFull() bool

IsFull checks if queue is full or not

func (*CircularQueue[T]) Length

func (q *CircularQueue[T]) Length() int

Length return current data length of queue

func (*CircularQueue[T]) Print

func (q *CircularQueue[T]) Print()

Print queue data

type LinkedQueue

type LinkedQueue[T any] struct {
	// contains filtered or unexported fields
}

LinkedQueue implements queue with link list

func NewLinkedQueue

func NewLinkedQueue[T any]() *LinkedQueue[T]

NewLinkedQueue return a empty LinkedQueue pointer

func (*LinkedQueue[T]) Back

func (q *LinkedQueue[T]) Back() (*T, error)

Back return back value of queue

func (*LinkedQueue[T]) Clear

func (q *LinkedQueue[T]) Clear()

Clear clear the queue data

func (*LinkedQueue[T]) Data

func (q *LinkedQueue[T]) Data() []T

Data return queue data

func (*LinkedQueue[T]) DeQueue

func (q *LinkedQueue[T]) DeQueue() (*T, error)

DeQueue delete head element of queue then return it, if queue is empty, return nil and error

func (*LinkedQueue[T]) EnQueue

func (q *LinkedQueue[T]) EnQueue(value T)

EnQueue add element into queue

func (*LinkedQueue[T]) Front

func (q *LinkedQueue[T]) Front() (*T, error)

Front return front value of queue

func (*LinkedQueue[T]) IsEmpty

func (q *LinkedQueue[T]) IsEmpty() bool

IsEmpty checks if queue is empty or not

func (*LinkedQueue[T]) Print

func (q *LinkedQueue[T]) Print()

Print all nodes info of queue link

func (*LinkedQueue[T]) Size

func (q *LinkedQueue[T]) Size() int

Size return length of queue data

Jump to

Keyboard shortcuts

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