aboutsummaryrefslogtreecommitdiff
path: root/set.go
diff options
context:
space:
mode:
authorGuangxiong Lin <[email protected]>2023-01-20 23:05:54 +0800
committerGuangxiong Lin <[email protected]>2023-01-20 23:24:56 +0800
commit3f6aeea8c795b8bff59c1a8b45700d7bc44da4b9 (patch)
tree63dbe7f72fd397a55023a014b9a4eff8ded45400 /set.go
downloadzk-3f6aeea8c795b8bff59c1a8b45700d7bc44da4b9.tar.gz
zk-3f6aeea8c795b8bff59c1a8b45700d7bc44da4b9.tar.bz2
zk-3f6aeea8c795b8bff59c1a8b45700d7bc44da4b9.zip
First commit
Diffstat (limited to 'set.go')
-rw-r--r--set.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/set.go b/set.go
new file mode 100644
index 0000000..760c9ae
--- /dev/null
+++ b/set.go
@@ -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)
+}