lru

package module
v0.0.0-...-e1f5aab Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2019 License: MIT Imports: 1 Imported by: 0

README

Usage

$ go test ./... -v
=== RUN   TestLRUCache
--- PASS: TestLRUCache (0.00s)
PASS
ok  	_/Users/joey/Work/opensource/code/go-lru	0.005s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRUCache

type LRUCache struct {
	Capacity int
	L        *list.List
	EMap     map[int]*list.Element
}

LRUCache indicates a LRUCache instance

func NewLRUCache

func NewLRUCache(capacity int) *LRUCache

NewLRUCache gets a new LRUCache instance

func (*LRUCache) Get

func (lru *LRUCache) Get(key int) int

Get return the value by key

func (*LRUCache) Length

func (lru *LRUCache) Length() int

Length returns the existing items count

func (*LRUCache) Put

func (lru *LRUCache) Put(key int, value int)

Put adds <key, value> into LRUCache

Jump to

Keyboard shortcuts

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