edu.rice.cs.plt.collect
Class EmptyCollection<T>

java.lang.Object
  extended by edu.rice.cs.plt.collect.EmptyCollection<T>
All Implemented Interfaces:
SizedIterable<T>, java.lang.Iterable<T>, java.util.Collection<T>
Direct Known Subclasses:
EmptyRelation, EmptySet

public abstract class EmptyCollection<T>
extends java.lang.Object
implements java.util.Collection<T>, SizedIterable<T>

Abstract parent class of immutable empty collections. Subclasses must implement equals(java.lang.Object) and hashCode().


Constructor Summary
EmptyCollection()
           
 
Method Summary
 boolean add(T o)
           
 boolean addAll(java.util.Collection<? extends T> c)
           
 void clear()
           
 boolean contains(java.lang.Object o)
           
 boolean containsAll(java.util.Collection<?> c)
           
abstract  boolean equals(java.lang.Object o)
           
 boolean hasFixedSize()
          true if this iterable is known to have a fixed size.
abstract  int hashCode()
           
 boolean isEmpty()
          Whether the iterable does not contain any elements.
 boolean isInfinite()
          true if the iterable is known to have infinite size.
 boolean isStatic()
          true if this iterable is unchanging.
 java.util.Iterator<T> iterator()
           
 boolean remove(java.lang.Object o)
           
 boolean removeAll(java.util.Collection<?> c)
           
 boolean retainAll(java.util.Collection<?> c)
           
 int size()
          Compute the number of elements in the iterable.
 int size(int bound)
          Compute the number of elements in the iterable, up to the given bound.
 java.lang.Object[] toArray()
           
<S> S[]
toArray(S[] a)
           
 java.lang.String toString()
          Returns "[]".
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

EmptyCollection

public EmptyCollection()
Method Detail

equals

public abstract boolean equals(java.lang.Object o)
Specified by:
equals in interface java.util.Collection<T>
Overrides:
equals in class java.lang.Object

hashCode

public abstract int hashCode()
Specified by:
hashCode in interface java.util.Collection<T>
Overrides:
hashCode in class java.lang.Object

size

public int size()
Description copied from interface: SizedIterable
Compute the number of elements in the iterable. If the size is infinite or too large to be represented as an int, Integer.MAX_VALUE should be returned. Otherwise, next() may be safely invoked on the iterator exactly this number of times.

Specified by:
size in interface SizedIterable<T>
Specified by:
size in interface java.util.Collection<T>

size

public int size(int bound)
Description copied from interface: SizedIterable
Compute the number of elements in the iterable, up to the given bound. If the size is infinite or greater than bound, bound is returned.

Specified by:
size in interface SizedIterable<T>
Parameters:
bound - Maximum result. Assumed to be nonnegative.

isEmpty

public boolean isEmpty()
Description copied from interface: SizedIterable
Whether the iterable does not contain any elements.

Specified by:
isEmpty in interface SizedIterable<T>
Specified by:
isEmpty in interface java.util.Collection<T>

isInfinite

public boolean isInfinite()
Description copied from interface: SizedIterable
true if the iterable is known to have infinite size. If true, an iterator over the iterable in its current state will never return false from hasNext().

Specified by:
isInfinite in interface SizedIterable<T>

hasFixedSize

public boolean hasFixedSize()
Description copied from interface: SizedIterable
true if this iterable is known to have a fixed size. This is the case if the iterable is immutable, or if changes can only replace values, not remove or add them. An infinite iterable may be fixed if it is guaranteed to never become finite.

Specified by:
hasFixedSize in interface SizedIterable<T>

isStatic

public boolean isStatic()
Description copied from interface: SizedIterable
true if this iterable is unchanging. This implies that hasFixedSize() is true, and that iterator() will always return the same (either == or equal() and immutable) elements in the same order. ("Immutable" here means that equals() invocations are consistent over time -- if two objects are equal, they will never become inequal, and vice versa.)

Specified by:
isStatic in interface SizedIterable<T>

contains

public boolean contains(java.lang.Object o)
Specified by:
contains in interface java.util.Collection<T>

containsAll

public boolean containsAll(java.util.Collection<?> c)
Specified by:
containsAll in interface java.util.Collection<T>

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface java.lang.Iterable<T>
Specified by:
iterator in interface java.util.Collection<T>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<T>

toArray

public <S> S[] toArray(S[] a)
Specified by:
toArray in interface java.util.Collection<T>

toString

public java.lang.String toString()
Returns "[]".

Overrides:
toString in class java.lang.Object

add

public boolean add(T o)
Specified by:
add in interface java.util.Collection<T>

addAll

public boolean addAll(java.util.Collection<? extends T> c)
Specified by:
addAll in interface java.util.Collection<T>

remove

public boolean remove(java.lang.Object o)
Specified by:
remove in interface java.util.Collection<T>

removeAll

public boolean removeAll(java.util.Collection<?> c)
Specified by:
removeAll in interface java.util.Collection<T>

retainAll

public boolean retainAll(java.util.Collection<?> c)
Specified by:
retainAll in interface java.util.Collection<T>

clear

public void clear()
Specified by:
clear in interface java.util.Collection<T>