core

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrOverflow = errors.New("data overflow")
)

Functions

func Dequeue

func Dequeue[T any](ctx context.Context, ds Queue[T]) (T, bool)

Dequeue is a safe function to read values from the ds, until the context is done.

func Enqueue

func Enqueue[T any](ctx context.Context, ds Queue[T], val T) bool

Enqueue is used as a safe function to write values into queues, ensuring that even if the q is full, we'll try to write the item until the context is done.

func Pop

func Pop[T any](ctx context.Context, ds Stack[T]) (T, bool)

Pop is a safe function to read values from the ds, until the context is done.

func Push

func Push[T any](ctx context.Context, ds Stack[T], val T) bool

Push is used as a safe function to write values into the ds, ensuring that even if the q is full, we'll try to write the item until the context is done.

Types

type DataStructureBase

type DataStructureBase interface {
	Size() int
	Empty() bool
	Full() bool
}

DataStructure is the base interface for all data structures.

type Queue

type Queue[T any] interface {
	Enqueue(T) bool
	Dequeue() (T, bool)

	DataStructureBase
}

Queue is the interface for working with a queue.

type Stack

type Stack[T any] interface {
	Push(T) bool
	Pop() (T, bool)

	DataStructureBase
}

Stack is the interface for working with a stack.

Jump to

Keyboard shortcuts

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