container

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2023 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 Comparabler

type Comparabler interface {
	Interface
}

Comparabler types that can be compared, with base types(todo)

type DelayQueue added in v1.0.2

type DelayQueue struct {
	C chan interface{}
	// contains filtered or unexported fields
}

DelayQueue is an unbounded blocking queue of *Delayed* elements, in which an element can only be taken when its delay has expired. The head of the queue is the *Delayed* element whose delay expired furthest in the past.

func NewDelayQueue added in v1.0.4

func NewDelayQueue(size int64) *DelayQueue

New creates an instance of delayQueue with the specified size.

func (*DelayQueue) PeekAndShift added in v1.0.2

func (dq *DelayQueue) PeekAndShift(t int64) (item *Item, delta int64)

func (*DelayQueue) Put added in v1.0.4

func (dq *DelayQueue) Put(v interface{}, expiration int64)

Put inserts the element into the current queue.

func (*DelayQueue) Take added in v1.0.4

func (dq *DelayQueue) Take() (item *Item)

TakeNoWait get a element from queue if no expired element, waits for an element to expire

func (*DelayQueue) TakeNoWait added in v1.0.4

func (dq *DelayQueue) TakeNoWait() (item *Item)

TakeNoWait, Take get a element from queue, if no expired element, return nil

type Float

type Float interface {
	~float32 | ~float64
}

Float float32 & float64

type InnerType

type InnerType interface {
	constraints.Float | constraints.Integer | String
}

InnerType all golang base type

type Integer

type Integer interface {
	Signed | Unsigned
}

Integer Signed & Unsigned

type Interface

type Interface interface {
	Less(a any) bool
}

Interface types that can be compared

type Item added in v1.0.2

type Item struct {
	V          interface{}
	Expiration int64
}

func (Item) Less added in v1.0.2

func (i Item) Less(j any) bool

type PriorityQueue

type PriorityQueue struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

PriorityQueue priority queue based container/heap

func NewPriorityqueue added in v1.0.2

func NewPriorityqueue(size int64) (pq *PriorityQueue)

InitPq initial a priority queue instance

func (*PriorityQueue) Empty added in v1.0.1

func (pq *PriorityQueue) Empty() bool

Empty

func (*PriorityQueue) Len

func (pq *PriorityQueue) Len() int

Len implement heap interface

func (*PriorityQueue) Less

func (pq *PriorityQueue) Less(i, j int) bool

Less implement heap interface

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() interface{}

Pop implement heap interface

func (*PriorityQueue) Popx

func (pq *PriorityQueue) Popx() (x Comparabler)

Popx pop a element from priority queue, removes and returns the top element

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(x interface{})

Push implement heap interface

func (*PriorityQueue) Pushx

func (pq *PriorityQueue) Pushx(x Comparabler)

Pushx push a element into priority queue

func (*PriorityQueue) Remove added in v1.0.4

func (pq *PriorityQueue) Remove(id int) (x Comparabler)

Remove remove from priority queue by id

func (*PriorityQueue) Swap

func (pq *PriorityQueue) Swap(i, j int)

Swap implement heap interface

func (*PriorityQueue) Topx

func (pq *PriorityQueue) Topx() (x Comparabler)

Top returns the top element but don't remove

func (*PriorityQueue) Update added in v1.0.4

func (pq *PriorityQueue) Update(id int, x Comparabler)

Update update priority queue elem by id

type Signed

type Signed interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

Signed is a constraint that permits any signed integer type.

type String

type String interface {
	~string | ~byte
}

String string & byte

type Unsigned

type Unsigned interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Unsigned is a constraint that permits any unsigned integer type.

Jump to

Keyboard shortcuts

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