edu.rice.cs.plt.collect
Class AbstractPredicateSet<T>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractSet<T>
edu.rice.cs.plt.collect.AbstractPredicateSet<T>
- All Implemented Interfaces:
- PredicateSet<T>, SizedIterable<T>, Predicate<java.lang.Object>, java.lang.Iterable<T>, java.util.Collection<T>, java.util.Set<T>
- Direct Known Subclasses:
- AbstractKeyBasedMap.EntrySet, AbstractRelation, AbstractRelation.InverseRelation, FilteredSet, IterableSet, SingletonSet, UnionSet
public abstract class AbstractPredicateSet<T>
- extends java.util.AbstractSet<T>
- implements PredicateSet<T>
An extension of AbstractSet that implements the PredicateSet interface. Subclasses must
define contains(java.lang.Object), AbstractCollection.iterator(), SizedIterable.isInfinite(), SizedIterable.hasFixedSize(),
and SizedIterable.isStatic(). Mutable sets must also implement AbstractCollection.add(E) and the iterator's
Iterator.remove() method. Subclasses may also find it useful to override
size(int), isEmpty(), AbstractCollection.remove(java.lang.Object), and AbstractCollection.clear() for improved
efficiency.
|
Method Summary |
abstract boolean |
contains(java.lang.Object o)
Test whether the set contains an object. |
boolean |
isEmpty()
Returns size(1) == 0. |
int |
size()
Returns size(Integer.MAX_VALUE). |
int |
size(int bound)
Computes the size by traversing the iterator (requires linear time). |
| Methods inherited from class java.util.AbstractSet |
equals, hashCode, removeAll |
| Methods inherited from class java.util.AbstractCollection |
add, addAll, clear, containsAll, iterator, remove, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Set |
add, addAll, clear, containsAll, equals, hashCode, iterator, remove, removeAll, retainAll, toArray, toArray |
AbstractPredicateSet
public AbstractPredicateSet()
contains
public abstract boolean contains(java.lang.Object o)
- Test whether the set contains an object. Overridden here to force subclasses to provide an
implementation. The default implementation (
AbstractCollection.contains(java.lang.Object)) is a linear search,
which is almost always unreasonable for a set.
- Specified by:
contains in interface Predicate<java.lang.Object>- Specified by:
contains in interface java.util.Collection<T>- Specified by:
contains in interface java.util.Set<T>- Overrides:
contains in class java.util.AbstractCollection<T>
isEmpty
public boolean isEmpty()
- Returns
size(1) == 0.
- Specified by:
isEmpty in interface SizedIterable<T>- Specified by:
isEmpty in interface java.util.Collection<T>- Specified by:
isEmpty in interface java.util.Set<T>- Overrides:
isEmpty in class java.util.AbstractCollection<T>
size
public int size()
- Returns
size(Integer.MAX_VALUE).
- Specified by:
size in interface SizedIterable<T>- Specified by:
size in interface java.util.Collection<T>- Specified by:
size in interface java.util.Set<T>- Specified by:
size in class java.util.AbstractCollection<T>
size
public int size(int bound)
- Computes the size by traversing the iterator (requires linear time).
- Specified by:
size in interface SizedIterable<T>
- Parameters:
bound - Maximum result. Assumed to be nonnegative.