Documentation ¶
Index ¶
- type Comparabler
- type DelayQueue
- type Float
- type InnerType
- type Integer
- type Interface
- type Item
- type PriorityQueue
- func (pq *PriorityQueue) Empty() bool
- func (pq *PriorityQueue) Len() int
- func (pq *PriorityQueue) Less(i, j int) bool
- func (pq *PriorityQueue) Pop() interface{}
- func (pq *PriorityQueue) Popx() (x Comparabler)
- func (pq *PriorityQueue) Push(x interface{})
- func (pq *PriorityQueue) Pushx(x Comparabler)
- func (pq *PriorityQueue) Remove(id int) (x Comparabler)
- func (pq *PriorityQueue) Swap(i, j int)
- func (pq *PriorityQueue) Topx() (x Comparabler)
- func (pq *PriorityQueue) Update(id int, x Comparabler)
- type Signed
- type String
- type Unsigned
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 InnerType ¶
type InnerType interface { constraints.Float | constraints.Integer | String }
InnerType all golang base type
type PriorityQueue ¶
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) Less ¶
func (pq *PriorityQueue) Less(i, j int) bool
Less 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) 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