g

package
v0.1.9 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exit added in v0.0.4

func Exit(cb func())

Types

type LRUCache

type LRUCache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

LRUCache lru cache (thread safe)

func NewLRUCache

func NewLRUCache[K comparable, V any](capacity int) *LRUCache[K, V]

NewLRUCache creates a LRUCache pointer instance.

func (*LRUCache[K, V]) Clear added in v0.0.6

func (l *LRUCache[K, V]) Clear()

Clear removes all items from the cache.

func (*LRUCache[K, V]) Delete

func (l *LRUCache[K, V]) Delete(key K) bool

Delete item from lru cache.

func (*LRUCache[K, V]) Foreach added in v0.1.2

func (l *LRUCache[K, V]) Foreach(cb func(value V))

Foreach applies a modification function to each value in the cache.

func (*LRUCache[K, V]) Get

func (l *LRUCache[K, V]) Get(key K) (V, bool)

Get value of key from lru cache.

func (*LRUCache[K, V]) Len

func (l *LRUCache[K, V]) Len() int

Len returns the number of items in the cache.

func (*LRUCache[K, V]) Put

func (l *LRUCache[K, V]) Put(key K, value V)

Put value of key into lru cache.

type LinkNode

type LinkNode[T any] struct {
	Value T
	Pre   *LinkNode[T]
	Next  *LinkNode[T]
}

LinkNode is a linkedlist node, which have a Value and Pre points to previous node, Next points to a next node of the link.

func NewLinkNode

func NewLinkNode[T any](value T) *LinkNode[T]

NewLinkNode return a LinkNode pointer

type Numeric

type Numeric interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64 | float32 | float64
}

type QueueNode

type QueueNode[T any] struct {
	Value T
	Next  *QueueNode[T]
}

QueueNode is a node in a queue, which have a Value and Next pointer points to next node in the queue.

func NewQueueNode

func NewQueueNode[T any](value T) *QueueNode[T]

NewQueueNode return a QueueNode pointer

type StackNode

type StackNode[T any] struct {
	Value T
	Next  *StackNode[T]
}

StackNode is a node in stack, which have a Value and Next pointer points to next node in the stack.

func NewStackNode

func NewStackNode[T any](value T) *StackNode[T]

NewStackNode return a StackNode pointer

type TreeNode

type TreeNode[T any] struct {
	Value T
	Left  *TreeNode[T]
	Right *TreeNode[T]
}

TreeNode is node of tree

func NewTreeNode

func NewTreeNode[T any](val T) *TreeNode[T]

NewTreeNode return a TreeNode pointer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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