diff options
author | Guangxiong Lin <[email protected]> | 2023-01-20 23:05:54 +0800 |
---|---|---|
committer | Guangxiong Lin <[email protected]> | 2023-01-20 23:24:56 +0800 |
commit | 3f6aeea8c795b8bff59c1a8b45700d7bc44da4b9 (patch) | |
tree | 63dbe7f72fd397a55023a014b9a4eff8ded45400 /set.go | |
download | zk-3f6aeea8c795b8bff59c1a8b45700d7bc44da4b9.tar.gz zk-3f6aeea8c795b8bff59c1a8b45700d7bc44da4b9.tar.bz2 zk-3f6aeea8c795b8bff59c1a8b45700d7bc44da4b9.zip |
First commit
Diffstat (limited to 'set.go')
-rw-r--r-- | set.go | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -0,0 +1,16 @@ +package main + +type Set[T comparable] map[T]bool + +func (s Set[T]) Contain(val T) bool { + _, ok := s[val] + return ok +} + +func (s Set[T]) Insert(val T) { + s[val] = true +} + +func (s Set[T]) Erase(val T) { + delete(s, val) +} |