Package org.jboss.util.collection
Class MapDelegateSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- org.jboss.util.collection.MapDelegateSet<E>
-
- Type Parameters:
E
- the element type
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Set<E>
- Direct Known Subclasses:
ConcurrentReferenceHashSet
,ConcurrentSet
,FastCopyHashSet
public class MapDelegateSet<E> extends java.util.AbstractSet<E> implements java.io.Serializable
Set implemented by a backing Map. It's serializable if the elements are serializable.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.Map<E,java.lang.Object>
map
The delegate mapprivate static java.lang.Object
PRESENT
The dummy objectprivate static long
serialVersionUID
The serialVersionUID
-
Constructor Summary
Constructors Constructor Description MapDelegateSet(java.util.Map<E,java.lang.Object> map)
Set the initial map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E o)
Adds the specified element to this set if it is not already present.void
clear()
Removes all of the elements from this set.boolean
contains(java.lang.Object o)
Returns true if this set contains the specified element.boolean
isEmpty()
Returns true if this set contains no elements.java.util.Iterator<E>
iterator()
Returns an iterator over the elements in this set.boolean
remove(java.lang.Object o)
Removes the specified element from this set if it is present.int
size()
Returns the number of elements in this set (its cardinality).java.lang.String
toString()
-
Methods inherited from class java.util.AbstractCollection
addAll, containsAll, retainAll, toArray, toArray
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
The serialVersionUID- See Also:
- Constant Field Values
-
map
private final java.util.Map<E,java.lang.Object> map
The delegate map
-
PRESENT
private static final java.lang.Object PRESENT
The dummy object
-
-
Constructor Detail
-
MapDelegateSet
public MapDelegateSet(java.util.Map<E,java.lang.Object> map)
Set the initial map.- Parameters:
map
- the initial map
-
-
Method Detail
-
iterator
public java.util.Iterator<E> iterator()
Returns an iterator over the elements in this set. The elements are returned in no particular order.- Specified by:
iterator
in interfacejava.util.Collection<E>
- Specified by:
iterator
in interfacejava.lang.Iterable<E>
- Specified by:
iterator
in interfacejava.util.Set<E>
- Specified by:
iterator
in classjava.util.AbstractCollection<E>
- Returns:
- an Iterator over the elements in this set.
- See Also:
ConcurrentModificationException
-
size
public int size()
Returns the number of elements in this set (its cardinality).
-
isEmpty
public boolean isEmpty()
Returns true if this set contains no elements.
-
contains
public boolean contains(java.lang.Object o)
Returns true if this set contains the specified element.
-
add
public boolean add(E o)
Adds the specified element to this set if it is not already present.
-
remove
public boolean remove(java.lang.Object o)
Removes the specified element from this set if it is present.
-
clear
public void clear()
Removes all of the elements from this set.
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<E>
-
-