cl

package
v0.0.0-...-a705ce1 Latest Latest
Warning

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

Go to latest
Published: May 19, 2017 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package cl provides a simple goroutine-safe capped list implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CappedList

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

CappedList is a capped list where old items are evicted to make room for new items.

func New

func New(limit int) *CappedList

New creates a new CappedList with the given item limit.

func (*CappedList) Add

func (cl *CappedList) Add(key Key, value interface{})

Add adds an item to the CappedList with the given key and value.

func (*CappedList) All

func (cl *CappedList) All() map[Key]interface{}

All return all elements in the CappedList.

func (*CappedList) Contains

func (cl *CappedList) Contains(key Key) bool

Test determines whether the CappedList contains an item, returning true or false.

func (*CappedList) Get

func (cl *CappedList) Get(key Key) (interface{}, bool)

Get returns an item from the list, returning the value and a bool representing whether or not it was found.

func (*CappedList) Len

func (cl *CappedList) Len() int

Len returns the number of entries in the CappedList.

func (*CappedList) Limit

func (cl *CappedList) Limit() int

Limit returns the capacity of the CappedList.

func (*CappedList) Remove

func (cl *CappedList) Remove(key Key)

Remove removes an item from the CappedList by key.

type Key

type Key interface{}

Key is any type that is comparable.

Jump to

Keyboard shortcuts

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