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 setV- the dummy value type in this map
- All Implemented Interfaces:
 java.io.Serializable,java.lang.Iterable<E>,java.util.Collection<E>,java.util.Set<E>
public final class MapBackedSet<E,V> extends java.lang.Object implements java.util.Set<E>, java.io.SerializableDecorates aMapto obtainSetbehaviour.This class is used to create a
Setwith the same properties as the key set of any map. Thus, a ReferenceSet can be created by wrapping aReferenceMapin an instance of this class.Most map implementation can be used to create a set by passing in dummy values. Exceptions include
BidiMapimplementations, as they require unique values.- Since:
 - 3.1
 - See Also:
 - Serialized Form
 
 
- 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(E obj)booleanaddAll(java.util.Collection<? extends E> coll)voidclear()booleancontains(java.lang.Object obj)booleancontainsAll(java.util.Collection<?> coll)booleanequals(java.lang.Object obj)inthashCode()booleanisEmpty()java.util.Iterator<E>iterator()static <E,V>
MapBackedSet<E,V>mapBackedSet(java.util.Map<E,? super V> map)Factory method to create a set from a map.static <E,V>
MapBackedSet<E,V>mapBackedSet(java.util.Map<E,? super V> map, V dummyValue)Factory method to create a set from a map.booleanremove(java.lang.Object obj)booleanremoveAll(java.util.Collection<?> coll)booleanremoveIf(java.util.function.Predicate<? super E> filter)booleanretainAll(java.util.Collection<?> coll)intsize()java.lang.Object[]toArray()<T> T[]toArray(T[] array) 
 - 
 
- 
- 
Method Detail
- 
mapBackedSet
public static <E,V> MapBackedSet<E,V> mapBackedSet(java.util.Map<E,? super V> map)
Factory method to create a set from a map.- Type Parameters:
 E- the element typeV- the dummy value type in the map- Parameters:
 map- the map to decorate, must not be null- Returns:
 - a new map backed set
 - Throws:
 java.lang.NullPointerException- if map is null- Since:
 - 4.0
 
 
- 
mapBackedSet
public static <E,V> MapBackedSet<E,V> mapBackedSet(java.util.Map<E,? super V> map, V dummyValue)
Factory method to create a set from a map.- Type Parameters:
 E- the element typeV- the dummy value type in the map- Parameters:
 map- the map to decorate, must not be nulldummyValue- the dummy value to use- Returns:
 - a new map backed set
 - Throws:
 java.lang.NullPointerException- if map is null- Since:
 - 4.0
 
 
- 
size
public int size()
 
- 
isEmpty
public boolean isEmpty()
 
- 
iterator
public java.util.Iterator<E> iterator()
 
- 
contains
public boolean contains(java.lang.Object obj)
 
- 
containsAll
public boolean containsAll(java.util.Collection<?> coll)
 
- 
add
public boolean add(E obj)
 
- 
addAll
public boolean addAll(java.util.Collection<? extends E> coll)
 
- 
remove
public boolean remove(java.lang.Object obj)
 
- 
removeIf
public boolean removeIf(java.util.function.Predicate<? super E> filter)
- Specified by:
 removeIfin interfacejava.util.Collection<E>- Since:
 - 4.4
 
 
- 
removeAll
public boolean removeAll(java.util.Collection<?> coll)
 
- 
retainAll
public boolean retainAll(java.util.Collection<?> coll)
 
- 
clear
public void clear()
 
- 
toArray
public java.lang.Object[] toArray()
 
- 
toArray
public <T> T[] toArray(T[] array)
 
- 
equals
public boolean equals(java.lang.Object obj)
 
 - 
 
 -