GithubHelp home page GithubHelp logo

lyrictian / hashmap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tidwall/hashmap

1.0 1.0 0.0 33 KB

A simple and efficient hashmap package for Go. Open addressing, robin hood hashing, and xxhash algorithm. Supports generics, Go 1.18.

License: ISC License

Go 100.00%

hashmap's Introduction

hashmap

GoDoc

An efficient hashmap implementation in Go.

This is a rewrite of the tidwall/rhh package to include Go 1.18 features.

Features

For ordered key-value data, check out the tidwall/btree package.

Using

To start using this package, install Go and run:

$ go get github.com/tidwall/hashmap

Getting Started

Installing

To start using hashmap, install Go and run go get:

$ go get github.com/tidwall/hashmap

This will retrieve the library.

Usage

The Map type works similar to a standard Go map, and includes the methods: Set, Get, Delete, Len, and Scan.

var m hashmap.Map[string, string]
m.Set("Hello", "Dolly!")
val, _ := m.Get("Hello")
fmt.Printf("%v\n", val)
val, _ = m.Delete("Hello")
fmt.Printf("%v\n", val)
val, _ = m.Get("Hello")
fmt.Printf("%v\n", val)

// Output:
// Dolly!
// Dolly!
//

The Set type is like Map but only for keys. It includes the methods: Insert, Contains, Delete, Len, and Scan.

var m hashmap.Set[string]
m.Insert("Andy")
m.Insert("Kate")
m.Insert("Janet")

fmt.Printf("%v\n", m.Contains("Kate"))
fmt.Printf("%v\n", m.Contains("Bob"))
fmt.Printf("%v\n", m.Contains("Andy"))

// Output:
// true
// false
// true

Performance

See BENCH.md for more info.

Contact

Josh Baker @tidwall

License

Source code is available under the MIT License.

hashmap's People

Contributors

tidwall avatar

Stargazers

 avatar

Watchers

 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.