org.jboss.cache.util
Class ImmutableSetCopy<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.jboss.cache.util.ImmutableSetCopy<E>
- All Implemented Interfaces:
- Externalizable, Serializable, Iterable<E>, Collection<E>, Set<E>
@Immutable
public class ImmutableSetCopy<E>
- extends AbstractSet<E>
- implements Externalizable
This is based on an ImmutableListCopy, with the assumption that the set passed in would ensure uniqueness of elements.
The constructor takes in a collection so the onus is on the caller to ensure that the collection passed in adheres to
Set semantics.
Typically used in place of the common idiom:
return Collections.unmodifiableSet(new HashSet( myInternalSet ));
- Since:
- 3.0
- Author:
- Manik Surtani (manik@jboss.org)
- See Also:
ImmutableListCopy,
Serialized Form
ImmutableSetCopy
public ImmutableSetCopy(Collection<E> set)
ImmutableSetCopy
public ImmutableSetCopy(E[] array)
- Assumes that the array passed in is "safe", i.e., is not referenced from elsewhere. Also assumes the array contains
elements such that the uniqueness required by a set is adhered to. Use with care!
- Parameters:
array - to reference
remove
public boolean remove(Object o)
- Specified by:
remove in interface Collection<E>- Specified by:
remove in interface Set<E>- Overrides:
remove in class AbstractCollection<E>
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAll in interface Collection<E>- Specified by:
addAll in interface Set<E>- Overrides:
addAll in class AbstractCollection<E>
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll in interface Collection<E>- Specified by:
retainAll in interface Set<E>- Overrides:
retainAll in class AbstractCollection<E>
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll in interface Collection<E>- Specified by:
removeAll in interface Set<E>- Overrides:
removeAll in class AbstractSet<E>
clear
public void clear()
- Specified by:
clear in interface Collection<E>- Specified by:
clear in interface Set<E>- Overrides:
clear in class AbstractCollection<E>
iterator
public Iterator<E> iterator()
- Specified by:
iterator in interface Iterable<E>- Specified by:
iterator in interface Collection<E>- Specified by:
iterator in interface Set<E>- Specified by:
iterator in class AbstractCollection<E>
size
public int size()
- Specified by:
size in interface Collection<E>- Specified by:
size in interface Set<E>- Specified by:
size in class AbstractCollection<E>
writeExternal
public void writeExternal(ObjectOutput out)
throws IOException
- Format:
- entry array size (int)
- elements (Object)
- Specified by:
writeExternal in interface Externalizable
- Parameters:
out - stream to write to
- Throws:
IOException
readExternal
public void readExternal(ObjectInput in)
throws IOException,
ClassNotFoundException
- See
writeExternal(java.io.ObjectOutput) for serialization format
- Specified by:
readExternal in interface Externalizable
- Parameters:
in - stream
- Throws:
IOException
ClassNotFoundException
Copyright © 2009 JBoss, a division of Red Hat. All Rights Reserved.