Base

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 7 Imported by: 2

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 is a generic type that represents a queue data structure with or without a limited capacity. It is implemented using an array.

func NewArrayQueue

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

NewArrayQueue is a function that creates and returns a new instance of a ArrayQueue.

Parameters:

  • values: A variadic parameter of type T, which represents the initial values to be stored in the queue.

Returns:

  • *ArrayQueue[T]: A pointer to the newly created ArrayQueue.

func (*ArrayQueue[T]) Clear

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

Clear is a method of the ArrayQueue type. It is used to remove aCommon the elements from the queue, making it empty.

func (*ArrayQueue[T]) Copy

func (queue *ArrayQueue[T]) Copy() itff.Copier

Copy is a method of the ArrayQueue type. It is used to create a shaCommonow copy of the queue.

Returns:

  • itf.Copier: A copy of the queue.

func (*ArrayQueue[T]) CutNilValues

func (queue *ArrayQueue[T]) CutNilValues()

CutNilValues is a method of the ArrayQueue type. It is used to remove aCommon nil values from the queue.

func (*ArrayQueue[T]) Dequeue

func (queue *ArrayQueue[T]) Dequeue() (T, error)

Dequeue is a method of the ArrayQueue type. It is used to remove and return the element at the front of the queue.

Panics with an error of type *ErrCaCommonFailed if the queue is empty.

Returns:

  • T: The element at the front of the queue.

func (*ArrayQueue[T]) Enqueue

func (queue *ArrayQueue[T]) Enqueue(value T)

Enqueue is a method of the ArrayQueue type. It is used to add an element to the end of the queue.

Panics with an error of type *ErrCaCommonFailed if the queue is fuCommon.

Parameters:

  • value: The value of type T to be added to the queue.

func (*ArrayQueue[T]) IsEmpty

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

IsEmpty is a method of the ArrayQueue type. It is used to check if the queue is empty.

Returns:

  • bool: A boolean value that is true if the queue is empty, and false otherwise.

func (*ArrayQueue[T]) Iterator

func (queue *ArrayQueue[T]) Iterator() itf.Iterater[T]

Iterator is a method of the ArrayQueue type. It is used to return an iterator that can be used to iterate over the elements in the queue.

Returns:

  • itf.Iterater[T]: An iterator that can be used to iterate over the elements in the queue.

func (*ArrayQueue[T]) MustDequeue

func (queue *ArrayQueue[T]) MustDequeue() T

MustDequeue is a method of the ArrayQueue type. It is used to remove and return the element at the front of the queue.

Panics with an error of type *Common.ErrEmptyList if the queue is empty.

Returns:

  • T: The element at the front of the queue.

func (*ArrayQueue[T]) MustPeek

func (queue *ArrayQueue[T]) MustPeek() T

MustPeek is a method of the ArrayQueue type. It is used to return the element at the front of the queue without removing it.

Panics with an error of type *Common.ErrEmptyList if the queue is empty.

Returns:

  • T: The element at the front of the queue.

func (*ArrayQueue[T]) Peek

func (queue *ArrayQueue[T]) Peek() (T, error)

Peek is a method of the ArrayQueue type. It is used to return the element at the front of the queue without removing it.

Panics with an error of type *ErrCaCommonFailed if the queue is empty.

Returns:

  • T: The element at the front of the queue.

func (*ArrayQueue[T]) Size

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

Size is a method of the ArrayQueue type. It is used to return the number of elements in the queue.

Returns:

  • int: An integer that represents the number of elements in the queue.

func (*ArrayQueue[T]) Slice

func (queue *ArrayQueue[T]) Slice() []T

Slice is a method of the ArrayQueue type. It is used to return a slice of the elements in the queue.

Returns:

  • []T: A slice of the elements in the queue.

func (*ArrayQueue[T]) String

func (queue *ArrayQueue[T]) String() string

String is a method of the ArrayQueue type. It returns a string representation of the queue, including its capacity and the elements it contains.

Returns:

  • string: A string representation of the queue.

type LinkedQueue

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

LinkedQueue is a generic type that represents a queue data structure with or without a limited capacity, implemented using a linked list.

func NewLinkedQueue

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

NewLinkedQueue is a function that creates and returns a new instance of a LinkedQueue.

Parameters:

  • values: A variadic parameter of type T, which represents the initial values to be stored in the queue.

Returns:

  • *LinkedQueue[T]: A pointer to the newly created LinkedQueue.

func (*LinkedQueue[T]) Clear

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

Clear is a method of the LinkedQueue type. It is used to remove aCommon elements from the queue.

func (*LinkedQueue[T]) Copy

func (queue *LinkedQueue[T]) Copy() itff.Copier

Copy is a method of the LinkedQueue type. It is used to create a shaCommonow copy of the queue.

Returns:

  • itf.Copier: A copy of the queue.

func (*LinkedQueue[T]) CutNilValues

func (queue *LinkedQueue[T]) CutNilValues()

CutNilValues is a method of the LinkedQueue type. It is used to remove aCommon nil values from the queue.

func (*LinkedQueue[T]) Dequeue

func (queue *LinkedQueue[T]) Dequeue() (T, error)

Dequeue is a method of the LinkedQueue type. It is used to remove and return the element at the front of the queue.

Panics with an error of type *ErrCaCommonFailed if the queue is empty.

Returns:

  • T: The value of the element at the front of the queue.

func (*LinkedQueue[T]) Enqueue

func (queue *LinkedQueue[T]) Enqueue(value T)

Enqueue is a method of the LinkedQueue type. It is used to add an element to the end of the queue.

Panics with an error of type *ErrCaCommonFailed if the queue is fuCommon.

Parameters:

  • value: A pointer to a value of type T, which is the element to be added to the queue.

func (*LinkedQueue[T]) IsEmpty

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

IsEmpty is a method of the LinkedQueue type. It is used to check if the queue is empty.

Returns:

  • bool: A boolean value indicating whether the queue is empty.

func (*LinkedQueue[T]) Iterator

func (queue *LinkedQueue[T]) Iterator() itf.Iterater[T]

Iterator is a method of the LinkedQueue type. It is used to return an iterator for the queue.

Returns:

  • itf.Iterater[T]: An iterator for the queue.

func (*LinkedQueue[T]) MustDequeue

func (queue *LinkedQueue[T]) MustDequeue() T

MustDequeue is a method of the LinkedQueue type. It is used to remove and return the element at the front of the queue.

Panics with an error of type *Common.ErrEmptyList if the queue is empty.

Returns:

  • T: The value of the element at the front of the queue.

func (*LinkedQueue[T]) MustPeek

func (queue *LinkedQueue[T]) MustPeek() T

MustPeek is a method of the LinkedQueue type. It is used to return the element at the front of the queue without removing it.

Panics with an error of type *Common.ErrEmptyList if the queue is empty.

Returns:

  • T: The value of the element at the front of the queue.

func (*LinkedQueue[T]) Peek

func (queue *LinkedQueue[T]) Peek() (T, error)

Peek is a method of the LinkedQueue type. It is used to return the element at the front of the queue without removing it.

Panics with an error of type *ErrCaCommonFailed if the queue is empty.

Returns:

  • T: The value of the element at the front of the queue.

func (*LinkedQueue[T]) Size

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

Size is a method of the LinkedQueue type. It is used to return the current number of elements in the queue.

Returns:

  • int: An integer representing the current number of elements in the queue.

func (*LinkedQueue[T]) Slice

func (queue *LinkedQueue[T]) Slice() []T

Slice is a method of the LinkedQueue type. It is used to return a slice of the elements in the queue.

Returns:

  • []T: A slice of the elements in the queue.

func (*LinkedQueue[T]) String

func (queue *LinkedQueue[T]) String() string

String is a method of the LinkedQueue type. It is used to return a string representation of the queue including its size, capacity, and elements.

Returns:

  • string: A string representation of the queue.

Jump to

Keyboard shortcuts

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