queue

package
v1.22.17 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Zlib Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIsFull = errors.New("is full")
View Source
var ErrIsReleased = errors.New("size is zero")
View Source
var PriorityType = reflect.TypeOf((*IPriority)(nil)).Elem()

Functions

func Run

func Run(c Call, lock sync.Locker, qu Queue)

Types

type Call added in v1.20.116

type Call struct {
	PopCount int
	Duration time.Duration
	Wait     func(dur time.Duration)
	Begin    func(count int) any
	Process  func(be any, data any)
	Quited   func(lock sync.Locker, qu Queue)
}

type Capacity added in v1.20.115

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

Capacity 固定长度的队列

func NewCapacity added in v1.20.115

func NewCapacity(capacity int) *Capacity

func (*Capacity) Add added in v1.20.115

func (sq *Capacity) Add(elem any) error

func (*Capacity) Empty added in v1.20.115

func (sq *Capacity) Empty() bool

func (*Capacity) Find added in v1.20.115

func (sq *Capacity) Find(fn IndexFunc) (any, int)

Find return index -1 not found.

func (*Capacity) Foreach added in v1.21.1

func (sq *Capacity) Foreach(fn IndexFunc)

func (*Capacity) Get added in v1.20.115

func (sq *Capacity) Get(index int) any

Get index -1 refers to the last.

func (*Capacity) Len added in v1.20.115

func (sq *Capacity) Len() int

func (*Capacity) Peek added in v1.20.115

func (sq *Capacity) Peek() any

func (*Capacity) Pop added in v1.20.115

func (sq *Capacity) Pop() any

func (*Capacity) Push added in v1.20.115

func (sq *Capacity) Push(elem any) error

func (*Capacity) SetLocation added in v1.21.3

func (sq *Capacity) SetLocation(l *time.Location)

func (*Capacity) ToList added in v1.20.115

func (sq *Capacity) ToList() []any

type Circular

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

Circular 环型队列

func NewCircular

func NewCircular(size int, resetFunc ResetFunc) *Circular

func (*Circular) Add

func (cr *Circular) Add(it any) error

func (*Circular) Empty

func (cr *Circular) Empty() bool

func (*Circular) Find

func (cr *Circular) Find(fn IndexFunc) (any, int)

Find return index -1 not found.

func (*Circular) Foreach added in v1.21.1

func (cr *Circular) Foreach(fn IndexFunc)

func (*Circular) Len

func (cr *Circular) Len() int

func (*Circular) Next

func (cr *Circular) Next(index int) (any, int)

func (*Circular) Peek

func (cr *Circular) Peek() any

func (*Circular) Pop

func (cr *Circular) Pop() any

func (*Circular) Push added in v1.20.118

func (cr *Circular) Push(it any) error

func (*Circular) Reset

func (cr *Circular) Reset()

type GeneratePriorityFn added in v1.21.3

type GeneratePriorityFn func() int64

func WithUnixNano added in v1.21.3

func WithUnixNano(l *time.Location) GeneratePriorityFn

type IPriority added in v1.3.58

type IPriority interface {
	GValue() any
	PValue() int64 //优先级值,越小越前
}

func NewPriorityItem added in v1.3.58

func NewPriorityItem(elem any, fn GeneratePriorityFn) IPriority

type IndexFunc

type IndexFunc func(v any, index int) bool

type Linked added in v1.20.115

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

Linked 链表式队列

func NewLinked added in v1.20.115

func NewLinked(capacity int) *Linked

func (*Linked) Add added in v1.20.115

func (lq *Linked) Add(val any) error

func (*Linked) AddTail added in v1.20.115

func (lq *Linked) AddTail(val any) error

func (*Linked) Cap added in v1.20.115

func (lq *Linked) Cap() int

func (*Linked) Empty added in v1.20.115

func (lq *Linked) Empty() bool

func (*Linked) Find added in v1.20.115

func (lq *Linked) Find(fn IndexFunc) (any, int)

Find return index -1 not found.

func (*Linked) Foreach added in v1.21.1

func (lq *Linked) Foreach(fn IndexFunc)

func (*Linked) Len added in v1.20.115

func (lq *Linked) Len() int

func (*Linked) Peek added in v1.20.115

func (lq *Linked) Peek() any

func (*Linked) Pop added in v1.20.115

func (lq *Linked) Pop() any

func (*Linked) Push added in v1.20.118

func (lq *Linked) Push(val any) error

func (*Linked) ToList added in v1.20.115

func (lq *Linked) ToList() []any

type Priority added in v1.20.115

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

Priority 优先级

func NewPriority added in v1.20.115

func NewPriority() *Priority

func (*Priority) Add added in v1.20.115

func (pq *Priority) Add(elem any) error

func (*Priority) Empty added in v1.20.115

func (pq *Priority) Empty() bool

func (*Priority) Find added in v1.20.115

func (pq *Priority) Find(fn IndexFunc) (any, int)

Find return index -1 not found.

func (*Priority) Foreach added in v1.21.1

func (pq *Priority) Foreach(fn IndexFunc)

func (*Priority) Head added in v1.20.115

func (pq *Priority) Head() IPriority

Head returns the first item of a Priority without removing it.

func (*Priority) Len added in v1.20.115

func (pq *Priority) Len() int

Len returns the Priority length.

func (*Priority) Peek added in v1.20.115

func (pq *Priority) Peek() any

func (*Priority) Pop added in v1.20.115

func (pq *Priority) Pop() any

Pop implements the heap.Interface.Pop. Removes and returns element Len() - 1.

func (*Priority) Push added in v1.20.115

func (pq *Priority) Push(x any) error

func (*Priority) Remove added in v1.20.115

func (pq *Priority) Remove(i int) any

Remove removes and returns the element at index i from the Priority.

func (*Priority) SetLocation added in v1.21.3

func (pq *Priority) SetLocation(l *time.Location)

type Queue

type Queue interface {
	Add(elem any) error
	Push(elem any) error
	Pop() any
	Peek() any
	Empty() bool
	Len() int
	Find(fn IndexFunc) (any, int)
	Foreach(fn IndexFunc)
}

type ResetFunc

type ResetFunc func()

Jump to

Keyboard shortcuts

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