Top "Hashset" questions

A HashSet encapsulates operations that allow for the comparison of elements in collections.

What's better for creating distinct data structures: HashSet or Linq's Distinct()?

I'm wondering whether I can get a consensus on which method is the better approach to creating a distinct set …

linq performance distinct hashset
HashSet removes duplicates but TreeSet does not?

Output of below class is : size is 3 size is 1 But if I change the TreeSet to a HashSet so line : …

java hashset treeset
Subtract HashSets (and return a copy)?

I've got a HashSet, var universe = new HashSet<int>(); And a bunch of subsets, var sets = new List&…

c# hashset
Why is HashSet<Point> so much slower than HashSet<string>?

I wanted to store some pixels locations without allowing duplicates, so the first thing comes to mind is HashSet<…

c# .net performance collections hashset
Mutable objects and hashCode

Have the following class: public class Member { private int x; private long y; private double d; public Member(int x, …

java immutability hashcode hashset
What is the time and space complexity of method retainAll when used on HashSets in Java?

For example in the code below: public int commonTwo(String[] a, String[] b) { Set common = new HashSet<String>(…

java big-o hashset
Java code using HashSet of longs doesn't work?

This simple Java code adds 2 to a set of long, and subsequently prints whether 2 is a member of the set: …

java long-integer hashset
How to avoid unchecked cast warning when cloning a HashSet?

I'm trying to make a shallow copy of a HashSet of Points called myHash. As of now, I have the …

java clone hashset
Why initialize HashSet<>(0) to zero?

I love a HashSet<>() and use this eagerly while initializing this with the default constructor: Set<Users&…

java constructor initialization hashset zero
HashSet Collisions in Java

I have a program for my Java class where I want to use hashSets to compare a directory of text …

java hashset collision