public final class MapBackedSet<E,V> extends Object implements Set<E>, Serializable
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.
Modifier and Type | Method and Description |
---|---|
boolean |
add(E obj) |
boolean |
addAll(Collection<? extends E> coll) |
void |
clear() |
boolean |
contains(Object obj) |
boolean |
containsAll(Collection<?> coll) |
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
static <E,V> MapBackedSet<E,V> |
mapBackedSet(Map<E,? super V> map)
Factory method to create a set from a map.
|
static <E,V> MapBackedSet<E,V> |
mapBackedSet(Map<E,? super V> map,
V dummyValue)
Factory method to create a set from a map.
|
boolean |
remove(Object obj) |
boolean |
removeAll(Collection<?> coll) |
boolean |
retainAll(Collection<?> coll) |
int |
size() |
Object[] |
toArray() |
<T> T[] |
toArray(T[] array) |
public static <E,V> MapBackedSet<E,V> mapBackedSet(Map<E,? super V> map)
E
- the element typeV
- the dummy value type in the mapmap
- the map to decorate, must not be nullIllegalArgumentException
- if set is nullpublic static <E,V> MapBackedSet<E,V> mapBackedSet(Map<E,? super V> map, V dummyValue)
E
- the element typeV
- the dummy value type in the mapmap
- the map to decorate, must not be nulldummyValue
- the dummy value to useIllegalArgumentException
- if map is nullpublic int size()
public boolean isEmpty()
public boolean contains(Object obj)
public boolean containsAll(Collection<?> coll)
containsAll
in interface Collection<E>
containsAll
in interface Set<E>
public boolean add(E obj)
public boolean addAll(Collection<? extends E> coll)
public boolean remove(Object obj)
public boolean removeAll(Collection<?> coll)
public boolean retainAll(Collection<?> coll)
public void clear()
public Object[] toArray()
public <T> T[] toArray(T[] array)
public boolean equals(Object obj)
Copyright © 2001–2013 The Apache Software Foundation. All rights reserved.