Convenience method to access any member of a set
This commit is contained in:
parent
9a543c2370
commit
429cff0a52
1 changed files with 7 additions and 0 deletions
|
|
@ -73,6 +73,13 @@ func (self *Set[T]) Iterable() map[T]struct{} {
|
|||
return self.items
|
||||
}
|
||||
|
||||
func (self *Set[T]) Any() T {
|
||||
for x := range self.items {
|
||||
return x
|
||||
}
|
||||
panic("set is empty")
|
||||
}
|
||||
|
||||
func (self *Set[T]) AsSlice() []T {
|
||||
return Keys(self.items)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue