Commit 4fd2ff85 authored by Phillip Couto's avatar Phillip Couto 🔨

Added Slice function to Strings set type.

parent 4087f87d
Pipeline #11249 passed with stage
in 12 seconds
......@@ -50,3 +50,12 @@ func (ss *Strings) Intersect(ss2 *Strings) *Strings {
data: results,
}
}
//Creates a slice of the values in the set, the values are not sorted
func (ss *Strings) Slice() []string {
results := make([]string, 0, len(ss.data))
for v := range ss.data {
results = append(results, v)
}
return results
}
......@@ -24,4 +24,7 @@ func TestStrings(t *testing.T) {
require.True(t, s3.Contains("B"))
require.False(t, s3.Contains("A"))
require.False(t, s3.Contains("C"))
s1Slice := s.Slice()
require.ElementsMatch(t, s1Slice, []string{"A", "B"})
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment