Documentation
¶
Overview ¶
The algorithms package contains useful data structures for re-use
Index ¶
- type LRUCache
- type PriorityQueue
- func (q *PriorityQueue[T]) Len() int
- func (q *PriorityQueue[T]) Less(i, j int) bool
- func (q *PriorityQueue[T]) Peek() (*T, error)
- func (q *PriorityQueue[T]) Pop() any
- func (pq *PriorityQueue[T]) PopItem() T
- func (q *PriorityQueue[T]) Push(x any)
- func (q *PriorityQueue[T]) PushItem(value T, priority int)
- func (q *PriorityQueue[T]) String() string
- func (q PriorityQueue[T]) Swap(i, j int)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LRUCache ¶
type LRUCache[K comparable, V any] struct { // contains filtered or unexported fields }
LRUCache represents the cache structure.
func NewLRUCache ¶
func NewLRUCache[K comparable, V any](capacity int) *LRUCache[K, V]
NewLRUCache initializes a new LRUCache with a given capacity.
func (*LRUCache[K, V]) Get ¶
Get retrieves the value of the key if it exists in the cache, otherwise returns zero value and false.
type PriorityQueue ¶
type PriorityQueue[T comparable] struct { // contains filtered or unexported fields }
func NewMaxCostPriorityQueue ¶
func NewMaxCostPriorityQueue[T comparable](capacity int) *PriorityQueue[T]
func NewMinCostPriorityQueue ¶
func NewMinCostPriorityQueue[T comparable](capacity int) *PriorityQueue[T]
func (*PriorityQueue[T]) Len ¶
func (q *PriorityQueue[T]) Len() int
Get the current size of the priority queue
func (*PriorityQueue[T]) Less ¶
func (q *PriorityQueue[T]) Less(i, j int) bool
func (*PriorityQueue[T]) Peek ¶
func (q *PriorityQueue[T]) Peek() (*T, error)
Retrieve the next item without popping it
func (*PriorityQueue[T]) Pop ¶
func (q *PriorityQueue[T]) Pop() any
func (*PriorityQueue[T]) Push ¶
func (q *PriorityQueue[T]) Push(x any)
func (*PriorityQueue[T]) PushItem ¶
func (q *PriorityQueue[T]) PushItem(value T, priority int)
PushItem a new item onto the priority queue
func (*PriorityQueue[T]) String ¶
func (q *PriorityQueue[T]) String() string
func (PriorityQueue[T]) Swap ¶
func (q PriorityQueue[T]) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.