From 0e57ff7eee4ac71d923f970d15889ad4d50f97a9 Mon Sep 17 00:00:00 2001 From: KN4CK3R Date: Wed, 12 Oct 2022 07:18:26 +0200 Subject: Add generic set type (#21408) This PR adds a generic set type to get rid of maps used as sets. Co-authored-by: wxiaoguang --- modules/base/tool.go | 9 --------- modules/base/tool_test.go | 9 --------- 2 files changed, 18 deletions(-) (limited to 'modules/base') diff --git a/modules/base/tool.go b/modules/base/tool.go index a981fd6c57..f1e4a3bf97 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -241,15 +241,6 @@ func Int64sToStrings(ints []int64) []string { return strs } -// Int64sToMap converts a slice of int64 to a int64 map. -func Int64sToMap(ints []int64) map[int64]bool { - m := make(map[int64]bool) - for _, i := range ints { - m[i] = true - } - return m -} - // Int64sContains returns if a int64 in a slice of int64 func Int64sContains(intsSlice []int64, a int64) bool { for _, c := range intsSlice { diff --git a/modules/base/tool_test.go b/modules/base/tool_test.go index 6685168bac..87de898e0b 100644 --- a/modules/base/tool_test.go +++ b/modules/base/tool_test.go @@ -214,16 +214,7 @@ func TestInt64sToStrings(t *testing.T) { ) } -func TestInt64sToMap(t *testing.T) { - assert.Equal(t, map[int64]bool{}, Int64sToMap([]int64{})) - assert.Equal(t, - map[int64]bool{1: true, 4: true, 16: true}, - Int64sToMap([]int64{1, 4, 16}), - ) -} - func TestInt64sContains(t *testing.T) { - assert.Equal(t, map[int64]bool{}, Int64sToMap([]int64{})) assert.True(t, Int64sContains([]int64{6, 44324, 4324, 32, 1, 2323}, 1)) assert.True(t, Int64sContains([]int64{2323}, 2323)) assert.False(t, Int64sContains([]int64{6, 44324, 4324, 32, 1, 2323}, 232)) -- cgit v1.2.3