edu.rice.cs.plt.collect
Class ConsList.Nonempty<T>

java.lang.Object
  extended by edu.rice.cs.plt.iter.AbstractIterable<T>
      extended by edu.rice.cs.plt.collect.ConsList<T>
          extended by edu.rice.cs.plt.collect.ConsList.Nonempty<T>
All Implemented Interfaces:
SizedIterable<T>, Composite, Serializable, Iterable<T>
Enclosing class:
ConsList<T>

public static class ConsList.Nonempty<T>
extends ConsList<T>

The nonempty variant of a ConsList. Contains a first value of the element type and a rest which is another list.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.rice.cs.plt.collect.ConsList
ConsList.Empty<T>, ConsList.Nonempty<T>
 
Constructor Summary
ConsList.Nonempty(T first, ConsList<? extends T> rest)
           
 
Method Summary
<Ret> Ret
apply(ConsVisitor<? super T,? extends Ret> visitor)
          Invoke the forNonempty case of a visitor
 T first()
           
 boolean isEmpty()
          Return false.
 Iterator<T> iterator()
          Create an iterator to traverse the list
 ConsList<? extends T> rest()
           
 int size()
          Return 1 + rest.size().
 int size(int bound)
          Return 1 + rest.size(bound - 1), or 0 if bound == 0.
 
Methods inherited from class edu.rice.cs.plt.collect.ConsList
append, compositeHeight, compositeSize, cons, empty, filter, first, hasFixedSize, isInfinite, isStatic, map, rest, reverse, singleton
 
Methods inherited from class edu.rice.cs.plt.iter.AbstractIterable
equals, hashCode, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConsList.Nonempty

public ConsList.Nonempty(T first,
                         ConsList<? extends T> rest)
Method Detail

first

public T first()

rest

public ConsList<? extends T> rest()

apply

public <Ret> Ret apply(ConsVisitor<? super T,? extends Ret> visitor)
Invoke the forNonempty case of a visitor

Specified by:
apply in class ConsList<T>

iterator

public Iterator<T> iterator()
Create an iterator to traverse the list

Specified by:
iterator in interface Iterable<T>
Specified by:
iterator in class ConsList<T>

isEmpty

public boolean isEmpty()
Return false.

Specified by:
isEmpty in interface SizedIterable<T>
Specified by:
isEmpty in class ConsList<T>

size

public int size()
Return 1 + rest.size().

Specified by:
size in interface SizedIterable<T>
Specified by:
size in class ConsList<T>

size

public int size(int bound)
Return 1 + rest.size(bound - 1), or 0 if bound == 0.

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