Compare commits

..

18 Commits

Author SHA1 Message Date
semantic-release-bot
93cc6d9fe2 release(rc): v1.1.1-rc.3
## [1.1.1-rc.3](https://git.ext.icikowski.pl/go/sets/compare/v1.1.1-rc.2...v1.1.1-rc.3) (2024-08-20)

### Build system and dependencies

* **deps:** update all non-major dependencies ([6aeec23](6aeec235db))
2024-08-20 21:17:55 +00:00
6aeec235db build(deps): update all non-major dependencies
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
2024-08-20 21:15:26 +00:00
semantic-release-bot
2f54bb4656 release(rc): v1.1.1-rc.2
## [1.1.1-rc.2](https://git.ext.icikowski.pl/go/sets/compare/v1.1.1-rc.1...v1.1.1-rc.2) (2024-08-20)

### Build system and dependencies

* **deps:** update golang docker tag to v1.23 ([c403a9d](c403a9d359))
2024-08-20 20:44:31 +00:00
c403a9d359
build(deps): update golang docker tag to v1.23
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
2024-08-20 22:42:33 +02:00
semantic-release-bot
86c8940f45 release(rc): v1.1.1-rc.1
## [1.1.1-rc.1](https://git.ext.icikowski.pl/go/sets/compare/v1.1.0...v1.1.1-rc.1) (2024-08-20)

### Build system and dependencies

* **deps:** update all major dependencies ([f4cb82a](f4cb82a73c))
2024-08-20 20:36:04 +00:00
f4cb82a73c build(deps): update all major dependencies
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/release Pipeline was successful
2024-06-01 00:02:57 +00:00
semantic-release-bot
c2fac0950e release(stable): v1.1.0
## [1.1.0](https://git.ext.icikowski.pl/go/sets/compare/v1.0.0...v1.1.0) (2024-05-27)

### Features

* **set:** add `NewFromSlice` function ([c228caa](c228caa309))

### Refactoring

* **comments:** beautify comments ([f8c0f0e](f8c0f0eddb))

### Continuous Integrations

* **deps:** pin `conventional-changelog-conventionalcommits` to version 7.x ([64f9954](64f99544f5))
* **init:** add initial CI configuration ([0ac2547](0ac25476ab))
* **renovate:** add Renovate bot configuration ([cf9d970](cf9d97099d))
* **test:** remove `group` directive ([2f56894](2f56894b6a))

### Build system and dependencies

* **deps:** update all non-major dependencies ([c375f89](c375f893e3))
* **deps:** update all non-major dependencies ([efd1b2b](efd1b2b347))
* **deps:** update all non-major dependencies ([b8a9834](b8a9834910))
* **deps:** update dependency @semantic-release/commit-analyzer to v12 ([6148fb1](6148fb1dcc))
* **deps:** update dependency @semantic-release/npm to v12 ([1c49da9](1c49da97cc))
* **deps:** update dependency @semantic-release/release-notes-generator to v13 ([38cf6db](38cf6dbfc2))
* **deps:** update dependency conventional-changelog-conventionalcommits to v8 ([7c2bc0f](7c2bc0f623))
* **deps:** update dependency semantic-release to v23 ([1223d34](1223d341e2))
* **deps:** update dependency semantic-release to v23.0.3 ([6cc61a8](6cc61a86ef))
* **deps:** update dependency semantic-release to v23.0.4 ([f45e6e5](f45e6e52ed))
* **deps:** update dependency semantic-release to v23.0.5 ([ff8d5cd](ff8d5cd4b3))
* **deps:** update dependency semantic-release to v23.0.8 ([28c7b91](28c7b9114b))
2024-05-27 23:08:20 +00:00
c9c1262313
docs(package): add simple README.md and package description
All checks were successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/release Pipeline was successful
2024-05-28 01:04:58 +02:00
semantic-release-bot
b1a9c1287c release(rc): v1.1.0-rc.1
## [1.1.0-rc.1](https://git.ext.icikowski.pl/go/sets/compare/v1.0.1-rc.10...v1.1.0-rc.1) (2024-05-27)

### Features

* **set:** add `NewFromSlice` function ([c228caa](c228caa309))

### Refactoring

* **comments:** beautify comments ([f8c0f0e](f8c0f0eddb))

### Continuous Integrations

* **test:** remove `group` directive ([2f56894](2f56894b6a))
2024-05-27 23:01:22 +00:00
c228caa309
feat(set): add NewFromSlice function
All checks were successful
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
2024-05-28 00:50:19 +02:00
f8c0f0eddb
refactor(comments): beautify comments 2024-05-28 00:44:13 +02:00
2f56894b6a
ci(test): remove group directive 2024-05-28 00:38:28 +02:00
semantic-release-bot
0785baf4b7 release(rc): v1.0.1-rc.10
## [1.0.1-rc.10](https://git.ext.icikowski.pl/go/sets/compare/v1.0.1-rc.9...v1.0.1-rc.10) (2024-05-21)

### Continuous Integrations

* **deps:** pin `conventional-changelog-conventionalcommits` to version 7.x ([64f9954](64f99544f5))

### Build system and dependencies

* **deps:** update all non-major dependencies ([c375f89](c375f893e3))
* **deps:** update dependency conventional-changelog-conventionalcommits to v8 ([7c2bc0f](7c2bc0f623))
2024-05-21 21:04:00 +00:00
64f99544f5
ci(deps): pin conventional-changelog-conventionalcommits to version 7.x
All checks were successful
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
2024-05-21 23:03:28 +02:00
c375f893e3 build(deps): update all non-major dependencies
Some checks failed
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/push/release Pipeline failed
ci/woodpecker/push/test Pipeline was successful
2024-05-15 13:15:14 +02:00
7c2bc0f623 build(deps): update dependency conventional-changelog-conventionalcommits to v8
Some checks failed
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
ci/woodpecker/push/release Pipeline failed
2024-05-04 00:02:30 +00:00
semantic-release-bot
10a4c8ea36 release(rc): v1.0.1-rc.9
## [1.0.1-rc.9](https://git.ext.icikowski.pl/go/sets/compare/v1.0.1-rc.8...v1.0.1-rc.9) (2024-04-12)

### Build system and dependencies

* **deps:** update dependency semantic-release to v23.0.8 ([28c7b91](28c7b9114b))
2024-04-12 12:43:42 +00:00
28c7b9114b build(deps): update dependency semantic-release to v23.0.8
All checks were successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/push/release Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
2024-04-12 12:41:50 +00:00
8 changed files with 1914 additions and 988 deletions

View File

@ -5,7 +5,6 @@ when:
steps:
test:
group: test
image: golang:1.22-alpine
image: golang:1.23-alpine
commands:
- go test -v ./...

View File

@ -1,3 +1,94 @@
## [1.1.1-rc.3](https://git.ext.icikowski.pl/go/sets/compare/v1.1.1-rc.2...v1.1.1-rc.3) (2024-08-20)
### Build system and dependencies
* **deps:** update all non-major dependencies ([6aeec23](https://git.ext.icikowski.pl/go/sets/commit/6aeec235db139a31b28a93aed4bb842153fac584))
## [1.1.1-rc.2](https://git.ext.icikowski.pl/go/sets/compare/v1.1.1-rc.1...v1.1.1-rc.2) (2024-08-20)
### Build system and dependencies
* **deps:** update golang docker tag to v1.23 ([c403a9d](https://git.ext.icikowski.pl/go/sets/commit/c403a9d359f993b1e1950d780328ae8b6ec34506))
## [1.1.1-rc.1](https://git.ext.icikowski.pl/go/sets/compare/v1.1.0...v1.1.1-rc.1) (2024-08-20)
### Build system and dependencies
* **deps:** update all major dependencies ([f4cb82a](https://git.ext.icikowski.pl/go/sets/commit/f4cb82a73cd46315dd5a2b8287eda14b3a4d87d1))
## [1.1.0](https://git.ext.icikowski.pl/go/sets/compare/v1.0.0...v1.1.0) (2024-05-27)
### Features
* **set:** add `NewFromSlice` function ([c228caa](https://git.ext.icikowski.pl/go/sets/commit/c228caa309db0637871134fbdb386c4af55d0f14))
### Refactoring
* **comments:** beautify comments ([f8c0f0e](https://git.ext.icikowski.pl/go/sets/commit/f8c0f0eddb6ad92b146f0c87c3f087124266db56))
### Continuous Integrations
* **deps:** pin `conventional-changelog-conventionalcommits` to version 7.x ([64f9954](https://git.ext.icikowski.pl/go/sets/commit/64f99544f52241ec9a2f9af1f30ba96aa8399af9))
* **init:** add initial CI configuration ([0ac2547](https://git.ext.icikowski.pl/go/sets/commit/0ac25476ab2bee29255cf3ee5172a0848a67ebdf))
* **renovate:** add Renovate bot configuration ([cf9d970](https://git.ext.icikowski.pl/go/sets/commit/cf9d97099df59f7906610100963320613091449b))
* **test:** remove `group` directive ([2f56894](https://git.ext.icikowski.pl/go/sets/commit/2f56894b6a3f85fd98fad9191c2e6a5f25dced9f))
### Build system and dependencies
* **deps:** update all non-major dependencies ([c375f89](https://git.ext.icikowski.pl/go/sets/commit/c375f893e3c2492b6a4763c4685b5afd841e6f5c))
* **deps:** update all non-major dependencies ([efd1b2b](https://git.ext.icikowski.pl/go/sets/commit/efd1b2b347dbaf5f7cf6ed18a4112a30e32359a8))
* **deps:** update all non-major dependencies ([b8a9834](https://git.ext.icikowski.pl/go/sets/commit/b8a9834910afd46073123648ea8afaa5749d8921))
* **deps:** update dependency @semantic-release/commit-analyzer to v12 ([6148fb1](https://git.ext.icikowski.pl/go/sets/commit/6148fb1dccc52ce9b252baa2e1f2ad9362bc103b))
* **deps:** update dependency @semantic-release/npm to v12 ([1c49da9](https://git.ext.icikowski.pl/go/sets/commit/1c49da97ccb172a825f5bc4cae602dcc4e235fb4))
* **deps:** update dependency @semantic-release/release-notes-generator to v13 ([38cf6db](https://git.ext.icikowski.pl/go/sets/commit/38cf6dbfc20ef0ff18de9aedad84f31832721404))
* **deps:** update dependency conventional-changelog-conventionalcommits to v8 ([7c2bc0f](https://git.ext.icikowski.pl/go/sets/commit/7c2bc0f623ff5a82b81e9784a92b9845738c62f0))
* **deps:** update dependency semantic-release to v23 ([1223d34](https://git.ext.icikowski.pl/go/sets/commit/1223d341e284b641fc35e6d247616dcaaf760a90))
* **deps:** update dependency semantic-release to v23.0.3 ([6cc61a8](https://git.ext.icikowski.pl/go/sets/commit/6cc61a86efc2a46f6c0d98517916011cfcdac444))
* **deps:** update dependency semantic-release to v23.0.4 ([f45e6e5](https://git.ext.icikowski.pl/go/sets/commit/f45e6e52ede310174421a6fe7f21f126aaaa24a4))
* **deps:** update dependency semantic-release to v23.0.5 ([ff8d5cd](https://git.ext.icikowski.pl/go/sets/commit/ff8d5cd4b30c895b2e58e8647648694731465981))
* **deps:** update dependency semantic-release to v23.0.8 ([28c7b91](https://git.ext.icikowski.pl/go/sets/commit/28c7b9114b2b63b55e5605e9a183bf84ea7500b0))
## [1.1.0-rc.1](https://git.ext.icikowski.pl/go/sets/compare/v1.0.1-rc.10...v1.1.0-rc.1) (2024-05-27)
### Features
* **set:** add `NewFromSlice` function ([c228caa](https://git.ext.icikowski.pl/go/sets/commit/c228caa309db0637871134fbdb386c4af55d0f14))
### Refactoring
* **comments:** beautify comments ([f8c0f0e](https://git.ext.icikowski.pl/go/sets/commit/f8c0f0eddb6ad92b146f0c87c3f087124266db56))
### Continuous Integrations
* **test:** remove `group` directive ([2f56894](https://git.ext.icikowski.pl/go/sets/commit/2f56894b6a3f85fd98fad9191c2e6a5f25dced9f))
## [1.0.1-rc.10](https://git.ext.icikowski.pl/go/sets/compare/v1.0.1-rc.9...v1.0.1-rc.10) (2024-05-21)
### Continuous Integrations
* **deps:** pin `conventional-changelog-conventionalcommits` to version 7.x ([64f9954](https://git.ext.icikowski.pl/go/sets/commit/64f99544f52241ec9a2f9af1f30ba96aa8399af9))
### Build system and dependencies
* **deps:** update all non-major dependencies ([c375f89](https://git.ext.icikowski.pl/go/sets/commit/c375f893e3c2492b6a4763c4685b5afd841e6f5c))
* **deps:** update dependency conventional-changelog-conventionalcommits to v8 ([7c2bc0f](https://git.ext.icikowski.pl/go/sets/commit/7c2bc0f623ff5a82b81e9784a92b9845738c62f0))
## [1.0.1-rc.9](https://git.ext.icikowski.pl/go/sets/compare/v1.0.1-rc.8...v1.0.1-rc.9) (2024-04-12)
### Build system and dependencies
* **deps:** update dependency semantic-release to v23.0.8 ([28c7b91](https://git.ext.icikowski.pl/go/sets/commit/28c7b9114b2b63b55e5605e9a183bf84ea7500b0))
## [1.0.1-rc.8](https://git.ext.icikowski.pl/go/sets/compare/v1.0.1-rc.7...v1.0.1-rc.8) (2024-04-12)

5
README.md Normal file
View File

@ -0,0 +1,5 @@
# `sets`
[![Go Report Card](https://goreportcard.com/badge/pkg.icikowski.pl/sets)](https://goreportcard.com/report/pkg.icikowski.pl/sets)
Sets and useful functions for working with them.

View File

@ -1,6 +1,6 @@
package sets
// Union returns a union of the given sets (left right)
// Union returns a union of the given sets (left right).
func Union[T comparable](left, right *Set[T]) *Set[T] {
left.mux.RLock()
right.mux.RLock()
@ -23,7 +23,7 @@ func Union[T comparable](left, right *Set[T]) *Set[T] {
}
}
// Intersection returns an intersection of the given sets (left ∩ right)
// Intersection returns an intersection of the given sets (left ∩ right).
func Intersection[T comparable](left, right *Set[T]) *Set[T] {
left.mux.RLock()
right.mux.RLock()
@ -43,7 +43,7 @@ func Intersection[T comparable](left, right *Set[T]) *Set[T] {
}
}
// Diff returns the relative complement of sets (left right)
// Diff returns the relative complement of sets (left right).
func Diff[T comparable](left, right *Set[T]) *Set[T] {
left.mux.RLock()
right.mux.RLock()
@ -63,7 +63,7 @@ func Diff[T comparable](left, right *Set[T]) *Set[T] {
}
}
// SymmetricDiff returns the symmetric difference between sets (left ⊖ right)
// SymmetricDiff returns the symmetric difference between sets (left ⊖ right).
func SymmetricDiff[T comparable](left, right *Set[T]) *Set[T] {
left.mux.RLock()
right.mux.RLock()
@ -88,7 +88,7 @@ func SymmetricDiff[T comparable](left, right *Set[T]) *Set[T] {
}
}
// Equal checks whether the sets are equal (left = right)
// Equal checks whether the sets are equal (left = right).
func Equal[T comparable](left, right *Set[T]) bool {
left.mux.RLock()
right.mux.RLock()

2762
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/*
Sets-related types & functions
Sets and useful functions for working with them.
*/
package sets

View File

@ -1,18 +1,18 @@
{
"private": true,
"name": "sets",
"version": "1.0.1-rc.8",
"version": "1.1.1-rc.3",
"scripts": {
"release": "./node_modules/.bin/semantic-release"
},
"devDependencies": {
"@saithodev/semantic-release-gitea": "^2.1.0",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/commit-analyzer": "^12.0.0",
"@semantic-release/commit-analyzer": "^13.0.0",
"@semantic-release/git": "^10.0.1",
"@semantic-release/npm": "^12.0.0",
"@semantic-release/release-notes-generator": "^13.0.0",
"conventional-changelog-conventionalcommits": "^7.0.2",
"semantic-release": "^23.0.0"
"@semantic-release/release-notes-generator": "^14.0.0",
"conventional-changelog-conventionalcommits": "^8.0.0",
"semantic-release": "^24.0.0"
}
}

19
set.go
View File

@ -4,13 +4,13 @@ import (
"sync"
)
// Set represents a set of values
// Set represents a set of values.
type Set[T comparable] struct {
store map[T]struct{}
mux sync.RWMutex
}
// New creates a new set
// New creates a new set.
func New[T comparable](data ...T) *Set[T] {
set := &Set[T]{
store: map[T]struct{}{},
@ -22,7 +22,12 @@ func New[T comparable](data ...T) *Set[T] {
return set
}
// Size returns number of elements in set
// NewFromSlice creates a new set from a slice.
func NewFromSlice[T comparable](data []T) *Set[T] {
return New[T](data...)
}
// Size returns number of elements in set.
func (s *Set[T]) Size() int {
s.mux.RLock()
defer s.mux.RUnlock()
@ -30,7 +35,7 @@ func (s *Set[T]) Size() int {
return len(s.store)
}
// Contains checks whether the value is contained in the set
// Contains checks whether the value is contained in the set.
func (s *Set[T]) Contains(val T) bool {
s.mux.RLock()
defer s.mux.RUnlock()
@ -39,7 +44,7 @@ func (s *Set[T]) Contains(val T) bool {
return ok
}
// Insert inserts a value into the set if the value was not already present
// Insert inserts a value into the set if the value was not already present.
func (s *Set[T]) Insert(val T) bool {
s.mux.Lock()
defer s.mux.Unlock()
@ -51,7 +56,7 @@ func (s *Set[T]) Insert(val T) bool {
return true
}
// Delete removes a value from the set if the value was already present
// Delete removes a value from the set if the value was already present.
func (s *Set[T]) Delete(val T) bool {
s.mux.Lock()
defer s.mux.Unlock()
@ -63,7 +68,7 @@ func (s *Set[T]) Delete(val T) bool {
return false
}
// Slice returns a slice which contains the elements from the set
// Slice returns a slice which contains the elements from the set.
func (s *Set[T]) Slice() []T {
s.mux.RLock()
defer s.mux.RUnlock()