3 ms·
You mentioned HashSets as another, distinct source of problems; I wanted to highlight that these two are the same thing behind the scenes, as the backing map's
by rzzzt 5y ago
You mentioned HashSets as another, distinct source of problems; I wanted to highlight that these two are the same thing behind the scenes, as the backing map's key set is doing the heavy lifting. It definitely is an implementation detail, and I can't say that all JDK variants employ the same trick, but a fair few of them do, given that most of them share the same set of java.lang classes.
- rzzzt 5y agoJust an addendum, sorry for the double post: I checked two additional implementations in the meantime. Apache Harmony: https://github.com/apache/harmony-classlib/blob/ee663b95e84093405985d9557a925b651a0f69b3/modules/luni/src/main/java/java/util/HashSet.java#L85-L96 https://github.com/apache/harmony-classlib/blob/ee663b95e840... GNU Classpath: https://github.com/ingelabs/classpath/blob/a96698f67357fddbe2026409d0113a35504bf6ab/java/util/HashSet.java#L142-L152 https://github.com/ingelabs/classpath/blob/a96698f67357fddbe...