Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
f258717f
Commit
f258717f
authored
Apr 29, 2015
by
deads2k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add StringSet.HasAny
parent
8fa21ebd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
set.go
pkg/util/set.go
+10
-0
set_test.go
pkg/util/set_test.go
+12
-0
No files found.
pkg/util/set.go
View file @
f258717f
...
...
@@ -75,6 +75,16 @@ func (s StringSet) HasAll(items ...string) bool {
return
true
}
// HasAny returns true if any items are contained in the set.
func
(
s
StringSet
)
HasAny
(
items
...
string
)
bool
{
for
_
,
item
:=
range
items
{
if
s
.
Has
(
item
)
{
return
true
}
}
return
false
}
// Difference returns a set of objects that are not in s2
// For example:
// s1 = {1, 2, 3}
...
...
pkg/util/set_test.go
View file @
f258717f
...
...
@@ -117,3 +117,15 @@ func TestStringSetDifference(t *testing.T) {
t
.
Errorf
(
"Unexpected contents: %#v"
,
d
.
List
())
}
}
func
TestStringSetHasAny
(
t
*
testing
.
T
)
{
a
:=
NewStringSet
(
"1"
,
"2"
,
"3"
)
if
!
a
.
HasAny
(
"1"
,
"4"
)
{
t
.
Errorf
(
"expected true, got false"
)
}
if
a
.
HasAny
(
"0"
,
"4"
)
{
t
.
Errorf
(
"expected false, got true"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment