collection

package
v0.0.0-...-3596c24 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 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 SafeMap

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

SafeMap provides a map alternative to avoid memory leak. This implementation is not needed until issue below fixed. https://github.com/golang/go/issues/20135 https://github.com/zeromicro/go-zero/blob/master/core/collection/safemap.go

func NewSafeMap

func NewSafeMap() *SafeMap

NewSafeMap returns a SafeMap.

func (*SafeMap) ContainsKey

func (m *SafeMap) ContainsKey(key interface{}) bool

func (*SafeMap) Del

func (m *SafeMap) Del(key interface{})

Del deletes the value with the given key from m.

func (*SafeMap) Dels

func (m *SafeMap) Dels(keys ...interface{})

func (*SafeMap) Get

func (m *SafeMap) Get(key interface{}) (interface{}, bool)

Get gets the value with the given key from m.

func (*SafeMap) GetDel

func (m *SafeMap) GetDel(key interface{}) (interface{}, bool)

GetDel 获取并删除, 返回删除对象,是否存在

func (*SafeMap) GetOrSet

func (m *SafeMap) GetOrSet(key, value interface{}) (interface{}, bool)

GetOrSet ...获取,不存在即设置,返回最新或者旧的值,是否原来存在标识

func (*SafeMap) Range

func (m *SafeMap) Range(fn func(k, v interface{}) error) (err error)

func (*SafeMap) Set

func (m *SafeMap) Set(key, value interface{})

Set sets the value into m with the given key.

func (*SafeMap) Size

func (m *SafeMap) Size() int

Size returns the size of m.

Jump to

Keyboard shortcuts

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