gitee.com/h79/goutils@v1.22.10/common/queue/queue.go (about)

     1  package queue
     2  
     3  import (
     4  	"reflect"
     5  )
     6  
     7  type Queue interface {
     8  	Add(elem any) error
     9  	Push(elem any) error
    10  	Pop() any
    11  	Peek() any
    12  	Empty() bool
    13  	Len() int
    14  	Find(fn IndexFunc) (any, int)
    15  	Foreach(fn IndexFunc)
    16  }
    17  
    18  type IndexFunc func(v any, index int) bool
    19  
    20  var PriorityType = reflect.TypeOf((*IPriority)(nil)).Elem()
    21  
    22  type IPriority interface {
    23  	GValue() any
    24  	PValue() int64 //优先级值,越小越前
    25  }