Class MapBackedSet<E,V>

java.lang.Object
org.apache.commons.collections4.set.MapBackedSet<E,V>
Type Parameters:
E - the type of the elements in this set
V - the dummy value type in this map
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>, Set<E>

public final class MapBackedSet<E,V> extends Object implements Set<E>, Serializable
Decorates a Map to obtain Set behaviour.

This class is used to create a Set with the same properties as the key set of any map. Thus, a ReferenceSet can be created by wrapping a ReferenceMap in an instance of this class.

Most map implementation can be used to create a set by passing in dummy values. Exceptions include BidiMap implementations, as they require unique values.

Since:
3.1
See Also:
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      Serialization version
      See Also:
    • map

      private final Map<E,? super V> map
      The map being used as the backing store
    • dummyValue

      private final V dummyValue
      The dummyValue to use
  • Constructor Details

    • MapBackedSet

      private MapBackedSet(Map<E,? super V> map, V dummyValue)
      Constructor that wraps (not copies).
      Parameters:
      map - the map to decorate, must not be null
      dummyValue - the dummy value to use
      Throws:
      NullPointerException - if map is null
  • Method Details