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