|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
ObjectAbstractCollection<E>
AbstractSet<E>
DerivedSet<B,E>
B - The type of elements in the backing set.E - The type of elements in this set.@Decorator(value=java.util.Set.class) public abstract class DerivedSet<B,E>
A set whose values are derived from an other set. The values are derived only when
requested, which make it possible to backup potentially large sets. Implementations
need only to overrides baseToDerived(B) and derivedToBase(E) methods.
This set do not supports null value, since null is used
when no mapping from base to this exists.
This class is serializable if the underlying base set is serializable
too.
This class is not thread-safe. Synchronizations (if wanted) are user's responsibility.
| utility/geotk-utility (download) | View source code for this class |
| Field Summary | |
|---|---|
protected Set<B> |
base
The base set whose values are derived from. |
| Constructor Summary | |
|---|---|
DerivedSet(Set<B> base,
Class<E> derivedType)
Creates a new derived set from the specified base set. |
|
| Method Summary | |
|---|---|
boolean |
add(E element)
Ensures that this set contains the specified element. |
protected abstract E |
baseToDerived(B element)
Transforms a value in the base set to a value in this set. |
boolean |
contains(Object element)
Returns true if this set contains the specified element. |
protected abstract B |
derivedToBase(E element)
Transforms a value in this set to a value in the base set. |
Class<E> |
getElementType()
Returns the derived element type. |
boolean |
isEmpty()
Returns true if this set contains no elements. |
Iterator<E> |
iterator()
Returns an iterator over the elements contained in this set. |
boolean |
remove(Object element)
Removes a single instance of the specified element from this set. |
int |
size()
Returns the number of elements in this set. |
| Methods inherited from class AbstractSet |
|---|
equals, hashCode, removeAll |
| Methods inherited from class AbstractCollection |
|---|
addAll, clear, containsAll, retainAll, toArray, toArray, toString |
| Methods inherited from class Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface Collection |
|---|
addAll, clear, containsAll, equals, hashCode, removeAll, retainAll, toArray, toArray |
| Methods inherited from interface Set |
|---|
addAll, clear, containsAll, retainAll, toArray, toArray |
| Field Detail |
|---|
protected final Set<B> base
baseToDerived(B),
derivedToBase(E)| Constructor Detail |
|---|
public DerivedSet(Set<B> base,
Class<E> derivedType)
base - The base set.derivedType - The type of elements in this derived set.| Method Detail |
|---|
public Class<E> getElementType()
getElementType in interface CheckedCollection<E>getElementType in interface CheckedContainer<E>protected abstract E baseToDerived(B element)
null.
element - A value in the base set.
element,
or null.protected abstract B derivedToBase(E element)
element - A value in this set.
public Iterator<E> iterator()
baseToDerived(B) for each element.
iterator in interface Iterable<E>iterator in interface Collection<E>iterator in interface Set<E>iterator in class AbstractCollection<E>public int size()
iterator.
size in interface Collection<E>size in interface Set<E>size in class AbstractCollection<E>public boolean isEmpty()
true if this set contains no elements.
isEmpty in interface Collection<E>isEmpty in interface Set<E>isEmpty in class AbstractCollection<E>true if this set contains no elements.public boolean contains(Object element)
true if this set contains the specified element.
The default implementation invokes
base.contains(derivedToBase(element)).
contains in interface Collection<E>contains in interface Set<E>contains in class AbstractCollection<E>element - object to be checked for containment in this set.
true if this set contains the specified element.
public boolean add(E element)
throws UnsupportedOperationException
base.add(derivedToBase(element)).
add in interface Collection<E>add in interface Set<E>add in class AbstractCollection<E>element - element whose presence in this set is to be ensured.
true if the set changed as a result of the call.
UnsupportedOperationException - if the base set doesn't
supports the add operation.
public boolean remove(Object element)
throws UnsupportedOperationException
base.remove(derivedToBase(element)).
remove in interface Collection<E>remove in interface Set<E>remove in class AbstractCollection<E>element - element to be removed from this set, if present.
true if the set contained the specified element.
UnsupportedOperationException - if the base set doesn't
supports the remove operation.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||