Documentation ¶
Index ¶
- Variables
- func AscendingComparator[T constraints.Ordered](t1, t2 T) int
- type Cache
- type CacheConfig
- func (cb *CacheConfig[K, V]) Build() *Cache[K, V]
- func (cb *CacheConfig[K, V]) Capacity(capacity int) *CacheConfig[K, V]
- func (cb *CacheConfig[K, V]) Loader(loader LoaderFn[K, V]) *CacheConfig[K, V]
- func (cb *CacheConfig[K, V]) NumShards(numShards int) *CacheConfig[K, V]
- func (cb *CacheConfig[K, V]) TTL(ttl time.Duration) *CacheConfig[K, V]
- type Comparator
- type Element
- type HashCoder
- type HashMap
- func (h *HashMap[K, V]) Delete(key K) (prev V, deleted bool)
- func (h *HashMap[K, V]) DeleteH(key K, hash uint64) (prev V, deleted bool)
- func (h *HashMap[K, V]) Get(key K) (value V, found bool)
- func (h *HashMap[K, V]) GetH(key K, hash uint64) (value V, found bool)
- func (h *HashMap[K, V]) Set(key K, value V) bool
- func (h *HashMap[K, V]) SetH(key K, value V, hash uint64) bool
- type Heap
- type HeapElement
- type IntKey
- type Key
- type List
- func (l *List[T]) Back() *Element[T]
- func (l *List[T]) Front() *Element[T]
- func (l *List[T]) Init() *List[T]
- func (l *List[T]) InsertAfter(v T, mark *Element[T]) *Element[T]
- func (l *List[T]) InsertBefore(v T, mark *Element[T]) *Element[T]
- func (l *List[T]) Len() int
- func (l *List[T]) MoveAfter(e, mark *Element[T])
- func (l *List[T]) MoveBefore(e, mark *Element[T])
- func (l *List[T]) MoveToBack(e *Element[T])
- func (l *List[T]) MoveToFront(e *Element[T])
- func (l *List[T]) PushBack(v T) *Element[T]
- func (l *List[T]) PushBackList(other *List[T])
- func (l *List[T]) PushFront(v T) *Element[T]
- func (l *List[T]) PushFrontList(other *List[T])
- func (l *List[T]) Remove(e *Element[T]) T
- type LoaderFn
- type StringKey
Constants ¶
This section is empty.
Variables ¶
var DefaultHasher = func(key string) uint64 { h := fnv.New64a() h.Write([]byte(fmt.Sprintf("%v", key))) return h.Sum64() }
var ErrNotFound = errors.New("not found")
Functions ¶
func AscendingComparator ¶
func AscendingComparator[T constraints.Ordered](t1, t2 T) int
Types ¶
type CacheConfig ¶
func NewBuilder ¶
func NewBuilder[K Key[K], V any]() *CacheConfig[K, V]
func (*CacheConfig[K, V]) Build ¶
func (cb *CacheConfig[K, V]) Build() *Cache[K, V]
func (*CacheConfig[K, V]) Capacity ¶
func (cb *CacheConfig[K, V]) Capacity(capacity int) *CacheConfig[K, V]
func (*CacheConfig[K, V]) Loader ¶
func (cb *CacheConfig[K, V]) Loader(loader LoaderFn[K, V]) *CacheConfig[K, V]
func (*CacheConfig[K, V]) NumShards ¶
func (cb *CacheConfig[K, V]) NumShards(numShards int) *CacheConfig[K, V]
func (*CacheConfig[K, V]) TTL ¶
func (cb *CacheConfig[K, V]) TTL(ttl time.Duration) *CacheConfig[K, V]
type Comparator ¶
type Element ¶
type Element[T any] struct { // The value stored with this element. Value T // contains filtered or unexported fields }
Element is an element of a linked list.
type Heap ¶
type Heap[T any] struct { // contains filtered or unexported fields }
func (*Heap[T]) Fix ¶
func (t *Heap[T]) Fix(he *HeapElement[T])
func (*Heap[T]) Peek ¶
func (t *Heap[T]) Peek() (item *HeapElement[T])
func (*Heap[T]) Pop ¶
func (t *Heap[T]) Pop() (item *HeapElement[T])
func (*Heap[T]) Push ¶
func (t *Heap[T]) Push(item T) *HeapElement[T]
func (*Heap[T]) Remove ¶
func (t *Heap[T]) Remove(he *HeapElement[T])
type HeapElement ¶
type HeapElement[T any] struct { Item T // contains filtered or unexported fields }
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
List represents a doubly linked list. The zero value for List is an empty list ready to use.
func (*List[T]) InsertAfter ¶
InsertAfter inserts a new element e with value v immediately after mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.
func (*List[T]) InsertBefore ¶
InsertBefore inserts a new element e with value v immediately before mark and returns e. If mark is not an element of l, the list is not modified. The mark must not be nil.
func (*List[T]) MoveAfter ¶
MoveAfter moves element e to its new position after mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.
func (*List[T]) MoveBefore ¶
MoveBefore moves element e to its new position before mark. If e or mark is not an element of l, or e == mark, the list is not modified. The element and mark must not be nil.
func (*List[T]) MoveToBack ¶
MoveToBack moves element e to the back of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*List[T]) MoveToFront ¶
MoveToFront moves element e to the front of list l. If e is not an element of l, the list is not modified. The element must not be nil.
func (*List[T]) PushBack ¶
PushBack inserts a new element e with value v at the back of list l and returns e.
func (*List[T]) PushBackList ¶
PushBackList inserts a copy of another list at the back of list l. The lists l and other may be the same. They must not be nil.
func (*List[T]) PushFront ¶
PushFront inserts a new element e with value v at the front of list l and returns e.
func (*List[T]) PushFrontList ¶
PushFrontList inserts a copy of another list at the front of list l. The lists l and other may be the same. They must not be nil.