Top "Hashset" questions

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

How to initialize HashSet values by construction?

I need to create a Set with initial values. Set<String> h = new HashSet<String>(); h.…

java collections constructor initialization hashset
How to Iterate over a Set/HashSet without an Iterator?

How can I iterate over a Set/HashSet without the following? Iterator iter = set.iterator(); while (iter.hasNext()) { System.out.…

java loops set hashset
Hashset vs Treeset

I've always loved trees, that nice O(n*log(n)) and the tidiness of them. However, every software engineer I've …

java hashset treeset
How to sort a HashSet?

For lists, we use the Collections.sort(List) method. What if we want to sort a HashSet?

java sorting collections set hashset
Define: What is a HashSet?

HashSet The C# HashSet data structure was introduced in the .NET Framework 3.5. A full list of the implemented members can …

c# hashset
Difference between HashSet and HashMap?

Apart from the fact that HashSet does not allow duplicate values, what is the difference between HashMap and HashSet? I …

java collections hashmap hashset
Why there is no ConcurrentHashSet against ConcurrentHashMap

HashSet is based on HashMap. If we look at HashSet<E> implementation, everything is been managed under HashMap&…

java collections concurrency hashmap hashset
How to calculate the intersection of two sets?

Possible Duplicate: Efficiently finding the intersection of a variable number of sets of strings Say, have two Hashset, how to …

java set intersection hashset
Does adding a duplicate value to a HashSet/HashMap replace the previous value

Please consider the below piece of code: HashSet hs = new HashSet(); hs.add("hi"); -- (1) hs.add("hi"); -- (2) hs.…

java hashmap duplicates hashset
Remove Elements from a HashSet while Iterating

So, if I try to remove elements from a Java HashSet while iterating, I get a ConcurrentModificationException. What is the …

java iteration hashmap hashset