Git Product home page Git Product logo

safemap's Introduction

safemap Build Status

一个线程安全的,支持泛型的,高性能的map库。基于orcaman/concurrent-map的实现和github.com/dolthub/maphash的hash算法。

usage

Import the package:

import (
	"github.com/smallnest/safemap"
)
go get github.com/smallnest/safemap@latest

The package is now imported under the "safemap" namespace.

example

	// Create a new map (K type is string, and V type is string too).
	m := safemap.New[string,string]()

	// Sets item within map, sets "bar" under key "foo"
	m.Set("foo", "bar")

	// Retrieve item from map.
	bar, ok := m.Get("foo")

	// Removes item under key "foo"
	m.Remove("foo")

	//  Create a new map (K type is int, and V type is string too).
	m2 := safemap.New[int,string]()

	// Sets item within map, sets "bar" under key 1
	m2.Set(1, "bar")

	// Retrieve item from map.
	bar, ok = m2.Get(1)

	// Removes item under key 1
	m2.Remove(1)

For more examples have a look at safemap_test.go.

Running tests:

go test github.com/smallnest/safemap

license

MIT (see LICENSE file)

safemap's People

Contributors

orcaman avatar grudzinski avatar sillydong avatar redbaron avatar wxb avatar imvexed avatar flyingfoxlee avatar sgodeletatbunnings avatar swilly22 avatar karlseguin avatar icholy avatar michaelyou avatar whilei avatar bcho avatar fosmjo avatar tic8 avatar minecrafter avatar janisz avatar tsl0922 avatar rschmukler avatar pczajkowski avatar colega avatar komarov avatar mkrufky avatar zerozshadow avatar jobberrt avatar codelingobot avatar choleraehyq avatar bokub avatar dreson4 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.