algorithm

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 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 SetType

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

type SetV2

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

func InstanceSetAndMapFromStructSlice

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

func (*SetV2[T]) Clear

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

func (*SetV2[T]) Clone

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

func (*SetV2[T]) Empty

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

func (*SetV2[T]) Has

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

func (*SetV2[T]) HasAnyItem

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

func (*SetV2[T]) Insert

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

func (*SetV2[T]) InsertAll

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

func (*SetV2[T]) Instance

func (s *SetV2[T]) Instance() *SetV2[T]

func (*SetV2[T]) InstanceFromSlice

func (s *SetV2[T]) InstanceFromSlice(slice *[]T) *SetV2[T]

func (*SetV2[T]) Remove

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

func (*SetV2[T]) Size

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

func (*SetV2[T]) ToArray

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

func (*SetV2[T]) TryInsert

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

Jump to

Keyboard shortcuts

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