Skip to content

Commit

Permalink
Fix PowerSet return values
Browse files Browse the repository at this point in the history
Previously, calling `PowerSet()` on a `threadSafeSet` would return a `threadUnsafeSet` of `threadUnsafeSet`s. Now it returns a `threadSafeSet` of `threadSafeSet`s.
  • Loading branch information
robyoder authored and deckarep committed Aug 31, 2018
1 parent 82e95d2 commit cbaa98b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion threadsafe.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,14 @@ func (set *threadSafeSet) String() string {

func (set *threadSafeSet) PowerSet() Set {
set.RLock()
ret := set.s.PowerSet()
unsafePowerSet := set.s.PowerSet().(*threadUnsafeSet)
set.RUnlock()

ret := &threadSafeSet{s: newThreadUnsafeSet()}
for subset := range unsafePowerSet.Iter() {
unsafeSubset := subset.(*threadUnsafeSet)
ret.Add(&threadSafeSet{s: *unsafeSubset})
}
return ret
}

Expand Down

0 comments on commit cbaa98b

Please sign in to comment.