util

package
v0.0.0-...-4409422 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToBytes

func AnyToBytes(n any) []byte

func Assert

func Assert(err error, msg string)

func BytesToAny

func BytesToAny[T any](b []byte) T

Types

type DLinkedNode

type DLinkedNode[T comparable] struct {
	// contains filtered or unexported fields
}

type Heap

type Heap[T any] struct {
	// contains filtered or unexported fields
}

func NewHeap

func NewHeap[T any](compare HeapCompareFunc[T], data []T) *Heap[T]

func (*Heap[T]) Fix

func (this *Heap[T]) Fix(i int)

func (*Heap[T]) Init

func (this *Heap[T]) Init()

func (*Heap[T]) Len

func (this *Heap[T]) Len() int

func (*Heap[T]) Peek

func (this *Heap[T]) Peek() T

func (*Heap[T]) Pop

func (this *Heap[T]) Pop() T

func (*Heap[T]) Push

func (this *Heap[T]) Push(x T)

func (*Heap[T]) Remove

func (this *Heap[T]) Remove(i int) T

func mycmp(a, b int) bool { return a < b }

type HeapCompareFunc

type HeapCompareFunc[T any] func(a, b T) bool

type LRUCache

type LRUCache[T comparable] struct {
	// contains filtered or unexported fields
}

func NewLRUCache

func NewLRUCache[T comparable](capacity int) *LRUCache[T]

func (*LRUCache[T]) Get

func (this *LRUCache[T]) Get(key T) (any, bool)

func (*LRUCache[T]) Put

func (this *LRUCache[T]) Put(key T, value any)

func (*LRUCache[T]) Remove

func (this *LRUCache[T]) Remove(key T)

func (*LRUCache[T]) Size

func (this *LRUCache[T]) Size() int

type Trie

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

func NewTrie

func NewTrie() *Trie

func (*Trie) Insert

func (t *Trie) Insert(word []string, value any)

func (*Trie) Search

func (t *Trie) Search(word []string) (latestValue any, isEnd bool)

同时支持,搜索,前缀匹配,最长前缀匹配

type TrieNode

type TrieNode struct {
	// contains filtered or unexported fields
}

func NewTrieNode

func NewTrieNode(e any) *TrieNode

Jump to

Keyboard shortcuts

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