HashSet contructor bug (always empty)?
See original GitHub issueHashSet(1,2,3).IsEmpty == true
Seems wrong to me.
I had a look into source and it seems the constructor fills a local variable set
but it is never used:
internal HSetInternal(IEnumerable<T> items, bool checkUniqueness = false)
{
var set = new HSetInternal<T>();
if (checkUniqueness)
{
foreach (var item in items)
{
set = set.TryAdd(item);
}
}
else
{
foreach (var item in items)
{
set = set.Add(item);
}
}
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Why HashSet sometimes doesn't add object when relying ...
I am working with a ConcurrentHashMap<String, HashSet<MyClass>> and sometimes when adding a newed up MyClass to the set, it will fail. The ...
Read more >HashSet<String [ ] > won't add new items
I'm able to find all permutations. And my idea was, to filter out the doubles by adding them to a HashSet. But the...
Read more >Unable to deserialize hashsets
Hi all, I created a demo project to test a serialization issue I am noticing in a project that was recently migrated to...
Read more >How do I initialize a static Set field? HashSet seems have ...
//An error: 'const' requires const constructor: 'HashSetImplementation.from ... is an empty list that will always remain the empty list, and
Read more >Performance of removeAll() in a HashSet
The removeAll method removes all the elements, that are contained in the collection: Set<Integer> set = new HashSet<Integer>(); set.add(1); ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thank you for fast bug fixing!
Thanks for very fast answer and for this fantastic library.
Yes, I already switched to
Set
for key types like int. There are some HashSets left with case-insensitive string keys (e.g. filenames).