File tree 2 files changed +8
-8
lines changed
2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 1
1
package mapx
2
2
3
- import (
4
- "github.com/zeiss/pkg/slices"
5
- )
3
+ import "github.com/zeiss/pkg/slices"
6
4
7
5
// Delete removes elements from a map by key.
8
6
func Delete [T1 comparable , T2 any ](m map [T1 ]T2 , keys ... T1 ) {
Original file line number Diff line number Diff line change 1
1
package slices
2
2
3
- import "github.com/zeiss/pkg/cast"
3
+ import (
4
+ "github.com/zeiss/pkg/cast"
5
+ )
4
6
5
7
// Any checks if any element in a slice satisfies a predicate.
6
8
func Any [T any ](fn func (v T ) bool , slice ... T ) bool {
@@ -106,13 +108,13 @@ func Last[T any](slice ...T) T {
106
108
107
109
// In checks if a value is in a slice.
108
110
func In [T comparable ](val T , slice ... T ) bool {
111
+ m := make (map [T ]bool , len (slice ))
109
112
for _ , v := range slice {
110
- if v == val {
111
- return true
112
- }
113
+ m [v ] = true
113
114
}
114
115
115
- return false
116
+ _ , ok := m [val ]
117
+ return ok
116
118
}
117
119
118
120
// Index returns the index of the first element in a slice that satisfies a predicate.
You can’t perform that action at this time.
0 commit comments