News for hackers. Stuff that matters.
Re:Map[string]interface{} in Go: a user's manual by cmckn on Monday July 26, 2021 @03:23PM (#27964097)
This is true for Java as well, a `HashSet` is just a `HashMap<T, Object>` where the value is:

  // Dummy value to associate with an Object in the backing Map
  private static final Object PRESENT = new Object();
https://github.com/openjdk/jdk/blob/master/src/java.base/sha...

A thread-safe implementation is available with `ConcurrentHashMap.newKeySet()`, which uses a similar approach:

  public static <K> KeySetView<K,Boolean> newKeySet() {
    return new KeySetView<K,Boolean>
      (new ConcurrentHashMap<K,Boolean>(), Boolean.TRUE);
  }
https://github.com/openjdk/jdk/blob/master/src/java.base/sha...

There are no comments on this comment yet.