https://github.com/bfontaine/set
:handbag: ultra-simple set for Go
https://github.com/bfontaine/set
go library
Last synced: 12 months ago
JSON representation
:handbag: ultra-simple set for Go
- Host: GitHub
- URL: https://github.com/bfontaine/set
- Owner: bfontaine
- License: mit
- Created: 2015-06-05T22:21:48.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2015-06-19T12:22:52.000Z (about 11 years ago)
- Last Synced: 2025-07-14T03:52:56.265Z (12 months ago)
- Topics: go, library
- Language: Go
- Homepage: https://godoc.org/github.com/bfontaine/set
- Size: 108 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Set
[](https://godoc.org/github.com/bfontaine/set)
[](https://travis-ci.org/bfontaine/set)
Package `set` provides an ultra-simple set implementation in Go.
## Features
* `int` and `string` sets
* Thread-safe
* `Add`, `Remove`, `Contains`, `Size`, `Iterate`. That’s all.
## Install
go get github.com/bfontaine/set
## Usage
```go
s := set.NewStringSet()
s.Add("foo")
s.Add("bar")
s.Contains("foo") // true
s.Contains("qux") // false
s.Remove("foo")
s.Contains("foo") // false
```
## Alternatives
* [golang-set](https://github.com/deckarep/golang-set): provides a lot more
features
## FAQ
### Why didn’t you use golang-set?
Because I needed a really simple `string` set and didn’t care about anything
other than the operations mentioned above. And golang-set uses `interface{}`,
which was an unnecessary overhead here.
### Why is there Ruby code here?
Set implementations are the same for all types so I use a small Ruby script and
`go generate` to generate the code for all types at once.