queue

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: May 15, 2024 License: MIT Imports: 0 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
}

func NewArrayQueue

func NewArrayQueue[T any](elems []T) *ArrayQueue[T]

NewArrayQueue returns a new queue with the provided elements.

func (*ArrayQueue[T]) Dequeue

func (a *ArrayQueue[T]) Dequeue(count int32) ([]T, error)

func (*ArrayQueue[T]) Enqueue

func (a *ArrayQueue[T]) Enqueue(elems []T) error

func (*ArrayQueue[T]) Len

func (a *ArrayQueue[T]) Len() int32

func (*ArrayQueue[T]) Pop

func (a *ArrayQueue[T]) Pop() (T, error)

func (*ArrayQueue[T]) Push

func (a *ArrayQueue[T]) Push(item T) error

type LinkedListQueue

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

func NewLinkedListQueue

func NewLinkedListQueue[T any](elems []T) *LinkedListQueue[T]

NewLinkedListQueue returns a new queue with the provided elements.

func (*LinkedListQueue[T]) Dequeue

func (q *LinkedListQueue[T]) Dequeue(count int32) ([]T, error)

Dequeue returns the first elements specified by the count param. If count is greater than the number of elements in the queue, all elements are returned.

func (*LinkedListQueue[T]) Enqueue

func (q *LinkedListQueue[T]) Enqueue(elems []T) error

Enqueue adds the provided elements to the queue.

func (*LinkedListQueue[T]) Len

func (q *LinkedListQueue[T]) Len() int32

Len returns the number of elements in the queue.

func (*LinkedListQueue[T]) Pop

func (q *LinkedListQueue[T]) Pop() (T, error)

Pop removes and returns the first element in the queue.

func (*LinkedListQueue[T]) Push

func (q *LinkedListQueue[T]) Push(e T) error

Push adds the provided element to the queue.

type Queue

type Queue[T any] interface {
	// Push adds the provided element to the queue.
	Push(item T) error
	// Pop removes and returns the first element in the queue.
	Pop() (T, error)
	// Len returns the number of elements in the queue.
	Len() int32
}

type WorkQueue

type WorkQueue[T any] interface {
	// Enqueue adds the provided elements to the queue.
	Enqueue(elems []T) error
	// Dequeue removes and returns the first count elements in the queue.
	Dequeue(count int32) ([]T, error)
	// Len returns the number of elements in the queue.
	Len() int32
}

Jump to

Keyboard shortcuts

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