Add a Set type matching the std HashSet API
cuviper opened this issue · comments
Just like in std
, it can start with the simple definition wrapping a map:
pub struct FlurryHashSet<T, S = RandomState> {
map: FlurryHashMap<T, (), S>,
}
The Java code's KeySetView
may also be of interest.
We now have a basic HashSet
type, but it'd be great to get something along the lines of HashMapRef
for HashSet
too!
We now have a basic
HashSet
type, but it'd be great to get something along the lines ofHashMapRef
forHashSet
too!
Is that a case of simply wrapping HashMapRef<T, ()>
in a newtype? I could work on that if that's the case.
I think you'd want to wrap HashSet
with HashSetRef
similar to how HashMap
is wrapped by HashMapRef
.
We'd be wrapping a wrapper either way...
I think wrapping HashMap<T, ()>
directly should make the type's layout flatter, but I'm not sure.
Ah, no, I was imagining we just do the same trick with HashSetRef
as with HashMapRef
, not that we wrap HashMapRef
to make HashSetRef
!
Ah, no, I was imagining we just do the same trick with
HashSetRef
as withHashMapRef
, not that we wrapHashMapRef
to makeHashSetRef
!
Makes sense.
@jonhoo What about the wrapping HashMap<T, ()>
directly proposal?
I think we should wrap HashSet
, because HashSet
actually has different methods than HashMap
, and having the wrapper also do the translation from set-like methods to map-like methods (which HashSet
is already doing) seems like unfortunate duplication.
Closed by #78!