day67

package
v0.0.0-...-36687a4 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LFUCache

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

LFUCache is a least-frequently-used cache. Every operation runs in O(1) time.

func NewLFUCache

func NewLFUCache(n int) *LFUCache

NewLFUCache returns a new instance of LFUCache.

func (*LFUCache) Get

func (lfu *LFUCache) Get(key interface{}) interface{}

Get gets the value at key. If no such key exists, return null.

func (*LFUCache) Set

func (lfu *LFUCache) Set(key, value interface{})

Set sets key to value. If there are already n items in the cache and we are adding a new item, then it should also remove the least frequently used item. If there is a tie, then the least recently used key should be removed.

Jump to

Keyboard shortcuts

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