org.semanticweb.elk.util.collections
Class LazySetIntersection<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<E>
org.semanticweb.elk.util.collections.LazySetIntersection<E>
- Type Parameters:
E - the type of the elements in this set
- All Implemented Interfaces:
- Iterable<E>, Collection<E>, Set<E>
public class LazySetIntersection<E>
- extends AbstractSet<E>
Represents a Set view for common elements of two sets. The
intersection is backed by the input sets, so changes to any of the sets are
reflected in the intersection. The main purpose of the class is to facilitate
iteration over intersection of sets without computing the intersection
explicitly. Iteration over the intersection is organized by iterating over
the elements in the smallest set and checking if the elements are present in
the other set. An element is contained in the intersection as reported by
contains if it is contained in all input sets. The size of the
intersection reported by size is the minimum of the sizes for the
sets. This way it is possible to use the result to build other
LazySetIntersection and LazySetUnion objects. If any of the
sets is modified while an iteration over the intersection is in progress, the
results of the iteration are undefined. The set intersection does not support
additions or removal of elements; if attempted, an
UnsupportedOperationException will be thrown.
- Author:
- Yevgeny Kazakov
- See Also:
LazySetUnion
LazySetIntersection
public LazySetIntersection(Set<E> firstSet,
Set<E> secondSet)
- Returns a new
Set view for intersection of two input sets.
- Parameters:
firstSet - the first set of the intersectionsecondSet - the second set of the intersection
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>
contains
public boolean contains(Object o)
- Specified by:
contains in interface Collection<E>- Specified by:
contains in interface Set<E>- Overrides:
contains in class AbstractCollection<E>
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>
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>
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty in interface Collection<E>- Specified by:
isEmpty in interface Set<E>- Overrides:
isEmpty in class AbstractCollection<E>
Copyright © 2011-2013 Department of Computer Science, University of Oxford. All Rights Reserved.