datastructure

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

type Queue[ITEM any] struct {
	// contains filtered or unexported fields
}

func (*Queue[ITEM]) Dequeue

func (q *Queue[ITEM]) Dequeue() (ITEM, error)

Dequeue implements QueueInterface.

func (*Queue[ITEM]) Enqueue

func (q *Queue[ITEM]) Enqueue(item ITEM) error

Enqueue implements QueueInterface.

func (*Queue[ITEM]) Front

func (q *Queue[ITEM]) Front() (ITEM, error)

Front implements QueueInterface.

func (*Queue[ITEM]) IsEmpty

func (q *Queue[ITEM]) IsEmpty() bool

IsEmpty implements QueueInterface.

func (*Queue[ITEM]) IsFull

func (q *Queue[ITEM]) IsFull() bool

IsFull implements QueueInterface.

func (*Queue[ITEM]) Items

func (q *Queue[ITEM]) Items() []ITEM

Items implements QueueInterface.

func (*Queue[ITEM]) WithMax

func (q *Queue[ITEM]) WithMax(max int) QueueInterface[ITEM]

WithMax implements QueueInterface.

type QueueInterface

type QueueInterface[ITEM any] interface {
	WithMax(max int) QueueInterface[ITEM]
	Enqueue(item ITEM) error
	Dequeue() (ITEM, error)
	IsEmpty() bool
	IsFull() bool
	Front() (ITEM, error)
	Items() []ITEM
}

func NewQueue

func NewQueue[ITEM any]() QueueInterface[ITEM]

type Set

type Set[E comparable] struct {
	Values map[E]bool
}

func (*Set[E]) Add

func (s *Set[E]) Add(values ...E)

func (*Set[E]) Clear

func (s *Set[E]) Clear()

func (*Set[E]) Del

func (s *Set[E]) Del(values ...E)

func (*Set[E]) DelIf

func (s *Set[E]) DelIf(condition func(value E) bool) SetInterface[E]

func (*Set[E]) IsEmpty

func (s *Set[E]) IsEmpty() bool

func (*Set[E]) IsExists

func (s *Set[E]) IsExists(value E) bool

func (*Set[E]) Size

func (s *Set[E]) Size() int

func (*Set[E]) Slice

func (s *Set[E]) Slice() []E

type SetInterface

type SetInterface[E comparable] interface {
	Add(values ...E)
	IsExists(value E) bool
	Del(values ...E)
	Slice() []E
	Clear()
	IsEmpty() bool
	Size() int
	DelIf(condition func(value E) bool) SetInterface[E]
}

func NewSet

func NewSet[E comparable](values ...E) SetInterface[E]

Set data type is like `slice` or `array` but without duplicate element and set element is unordered element

Jump to

Keyboard shortcuts

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