question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

HashSet contructor bug (always empty)?

See original GitHub issue

HashSet(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:closed
  • Created 7 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
StefanBertelscommented, Jan 27, 2017

Thank you for fast bug fixing!

0reactions
StefanBertelscommented, Jan 24, 2017

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).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found