safe_map

package
v0.0.0-...-1ec2636 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2019 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

线程安全的map。

示例:

var safeMap SafeMap = New()

safeMap.Set(13, 14)
safeMap.Set(15, "hello")
e := safeMap.Iterate(func(key interface{}, value interface{}) error {
	fmt.Println(key, value)
	return nil
})
if e != nil {
	fmt.Println(e.Error())
}

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
}

func New

func New(capacity ...int) *SafeMap

func (*SafeMap) Del

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

func (*SafeMap) Get

func (sm *SafeMap) Get(key interface{}) (value interface{}, exist bool)

func (*SafeMap) GetAndDo

func (sm *SafeMap) GetAndDo(key interface{}, do func(value interface{}, exist bool))

获取某个元素并做一些处理

func (*SafeMap) Iterate

func (sm *SafeMap) Iterate(iter func(key interface{}, value interface{}) error) error

遍历SafeMap中的所有元素

func (*SafeMap) Len

func (sm *SafeMap) Len() (length int)

func (*SafeMap) Set

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

Jump to

Keyboard shortcuts

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