algorithm

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BSTree

type BSTree[T Priority] struct {
	Left  *BSTree[T]
	Right *BSTree[T]
	// contains filtered or unexported fields
}

func NewBSTNode

func NewBSTNode[T Priority](data T) *BSTree[T]

NewBSTNode Attention: data need implement Priority

func (*BSTree[T]) Data

func (p *BSTree[T]) Data() T

func (*BSTree[T]) Has

func (p *BSTree[T]) Has(newNode *BSTree[T]) bool

func (*BSTree[T]) Insert

func (p *BSTree[T]) Insert(newNode *BSTree[T]) *BSTree[T]

func (*BSTree[T]) Maximum

func (p *BSTree[T]) Maximum() *BSTree[T]

func (*BSTree[T]) Merge

func (p *BSTree[T]) Merge(b *BSTree[T]) *BSTree[T]

func (*BSTree[T]) Minimum

func (p *BSTree[T]) Minimum() *BSTree[T]

func (*BSTree[T]) PreTravel

func (p *BSTree[T]) PreTravel(list *[]T)

func (*BSTree[T]) Remove

func (p *BSTree[T]) Remove(newNode *BSTree[T]) *BSTree[T]

func (*BSTree[T]) ToArray

func (p *BSTree[T]) ToArray() []T

type CanHashUnique

type CanHashUnique[T SetType] interface {
	Unique() T
}

type Priority

type Priority interface {
	Less(i, j interface{}) bool
	Equal(i, j interface{}) bool
	Empty() bool
}

type Queue

type Queue[T QueueType, K any] struct {
	// contains filtered or unexported fields
}

func (*Queue[T, K]) Dequeue

func (q *Queue[T, K]) Dequeue() K

func (*Queue[T, K]) Enqueue

func (q *Queue[T, K]) Enqueue(key T, item K)

func (*Queue[T, K]) Exists

func (q *Queue[T, K]) Exists(key T) bool

func (*Queue[T, K]) Instance

func (q *Queue[T, K]) Instance(opts ...QueueOption) *Queue[T, K]

func (*Queue[T, K]) Size

func (q *Queue[T, K]) Size() int64

type QueueOption

type QueueOption func(opts *QueueOptions)

func WithRemoveTicker

func WithRemoveTicker(duration time.Duration) QueueOption

定时移除队头

type QueueOptions

type QueueOptions struct {
	// contains filtered or unexported fields
}

type QueueType

type QueueType interface {
	~string | ~int | ~uint32 | ~int64
}

type Set added in v0.0.11

type Set[T SetType] struct {
	// contains filtered or unexported fields
}

func Instance added in v0.0.11

func Instance[T SetType]() *Set[T]

func InstanceFromSlice added in v0.0.11

func InstanceFromSlice[T SetType](slice *[]T) *Set[T]

func InstanceSetAndMapFromStructSlice

func InstanceSetAndMapFromStructSlice[T SetType, K CanHashUnique[T]](slice []K) (*Set[T], map[T]K)

func (*Set[T]) Clear added in v0.0.11

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

func (*Set[T]) Clone added in v0.0.11

func (s *Set[T]) Clone() *Set[T]

func (*Set[T]) Empty added in v0.0.11

func (s *Set[T]) Empty() bool

func (*Set[T]) Has added in v0.0.11

func (s *Set[T]) Has(val T) bool

func (*Set[T]) HasAnyItem added in v0.0.11

func (s *Set[T]) HasAnyItem(val ...T) bool

func (*Set[T]) Insert added in v0.0.11

func (s *Set[T]) Insert(val T) *Set[T]

func (*Set[T]) InsertAll added in v0.0.11

func (s *Set[T]) InsertAll(val ...T) *Set[T]

func (*Set[T]) Remove added in v0.0.11

func (s *Set[T]) Remove(val T)

func (*Set[T]) Size added in v0.0.11

func (s *Set[T]) Size() uint

func (*Set[T]) ToArray added in v0.0.11

func (s *Set[T]) ToArray() []T

func (*Set[T]) TryInsert added in v0.0.11

func (s *Set[T]) TryInsert(val T) (*Set[T], bool)

type SetType

type SetType interface {
	~string | ~int | ~uint32 | ~int64
}

Jump to

Keyboard shortcuts

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