Documentation
¶
Index ¶
- func Compare[T constraints.Ordered](v1, v2 T) int
- type Comparable
- type Container
- type Float32
- type Float64
- type Int
- type Int16
- type Int32
- type Int64
- type Int8
- type PriorityQueue
- func (pq *PriorityQueue[T]) Add(item T)
- func (pq *PriorityQueue[T]) Clear()
- func (pq *PriorityQueue[T]) Contains(val T) bool
- func (pq *PriorityQueue[T]) IsEmpty() bool
- func (pq *PriorityQueue[T]) Len() int
- func (pq *PriorityQueue[T]) Peek() (val T, exist bool)
- func (pq *PriorityQueue[T]) Poll() (val T, exist bool)
- func (pq *PriorityQueue[T]) Remove(val T)
- type String
- type Time
- type Uint
- type Uint16
- type Uint32
- type Uint64
- type Uint8
- type Uintptr
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Compare ¶
func Compare[T constraints.Ordered](v1, v2 T) int
Types ¶
type Comparable ¶
type Comparable interface {
CompareTo(Comparable) int
}
Comparable method CompareTo(Comparable) should return a negative number when v1 < v2, a positive number when v1 > v2 and zero when v1 == v2.
type Container ¶
type Container[T Comparable] struct { Items []T // container data Desc bool // asc or desc, default asc. }
type Float32 ¶
type Float32 float32
func (Float32) CompareTo ¶
func (v1 Float32) CompareTo(v2 Comparable) int
type Float64 ¶
type Float64 float64
func (Float64) CompareTo ¶
func (v1 Float64) CompareTo(v2 Comparable) int
type PriorityQueue ¶
type PriorityQueue[T Comparable] struct { // contains filtered or unexported fields }
PriorityQueue represents an unbounded priority queue based on a priority heap. It implements heap.Interface.
func NewPriorityQueue ¶
func NewPriorityQueue[T Comparable](maxHeap bool, items ...T) *PriorityQueue[T]
NewPriorityQueue initializes and returns an Queue, default min heap.
func (*PriorityQueue[T]) Add ¶
func (pq *PriorityQueue[T]) Add(item T)
Add inserts the specified element into this priority queue.
func (*PriorityQueue[T]) Clear ¶
func (pq *PriorityQueue[T]) Clear()
Clear removes all the elements from this priority queue.
func (*PriorityQueue[T]) Contains ¶
func (pq *PriorityQueue[T]) Contains(val T) bool
Contains returns true if this queue contains the specified element.
func (*PriorityQueue[T]) IsEmpty ¶
func (pq *PriorityQueue[T]) IsEmpty() bool
IsEmpty returns true if this list contains no elements.
func (*PriorityQueue[T]) Len ¶
func (pq *PriorityQueue[T]) Len() int
Len returns the length of this priority queue.
func (*PriorityQueue[T]) Peek ¶
func (pq *PriorityQueue[T]) Peek() (val T, exist bool)
Peek retrieves, but does not remove, the head of this queue, or return nil if this queue is empty.
func (*PriorityQueue[T]) Poll ¶
func (pq *PriorityQueue[T]) Poll() (val T, exist bool)
Poll retrieves and removes the head of the this queue, or return nil if this queue is empty.
func (*PriorityQueue[T]) Remove ¶
func (pq *PriorityQueue[T]) Remove(val T)
Remove a single instance of the specified element from this queue, if it is present. It returns false if the target value isn't present, otherwise returns true.
type String ¶
type String string
func (String) CompareTo ¶
func (v1 String) CompareTo(v2 Comparable) int
type Uint16 ¶
type Uint16 uint16
func (Uint16) CompareTo ¶
func (v1 Uint16) CompareTo(v2 Comparable) int
type Uint32 ¶
type Uint32 uint32
func (Uint32) CompareTo ¶
func (v1 Uint32) CompareTo(v2 Comparable) int