lrulist

package
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InsertStrategy

type InsertStrategy int
const (
	InsertFront InsertStrategy = iota
	InsertAverage
)

type LruList

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

func New

func New(updateInterval time.Duration, insertStrategy InsertStrategy) *LruList

func NewWithList

func NewWithList(updateInterval time.Duration, insertStrategy InsertStrategy, list []interface{}) *LruList

func (*LruList) Close

func (l *LruList) Close() (err error)

func (*LruList) GetListCopy

func (l *LruList) GetListCopy() []*Node

GetListCopy should be called when you want to traverse the list

func (*LruList) GiveBackListCopy

func (l *LruList) GiveBackListCopy(list []*Node)

GiveBackListCopy should be called when the list copy is no longer used

func (*LruList) Insert

func (l *LruList) Insert(val interface{}) *Node

spend O(n) time to insert

func (*LruList) Promote

func (l *LruList) Promote(node *Node)

promote but lazy sort. O(1)

func (*LruList) Remove

func (l *LruList) Remove(node *Node)

O(n) scan to remove a node

type Node

type Node struct {
	Val interface{}
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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