|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.collect.ConsVisitor<T,Ret>
public abstract class ConsVisitor<T,Ret>
A visitor for ConsLists. Implementations handle the two list variants:
ConsList.Empty and ConsList.Nonempty. For convenience, visitors may
also be treated as Lambdas -- the value method is implemented to
apply the visitor. A number of standard list visitors are also provided, either as static
fields or static methods.
| Constructor Summary | |
|---|---|
ConsVisitor()
|
|
| Method Summary | ||
|---|---|---|
static
|
append(ConsList<? extends T> rest)
Appends the given list to the end of another list |
|
static
|
filter(Predicate<? super T> pred)
Filters a list to contain only those elements accepted by the given predicate |
|
static
|
first()
Attempt to access the first of the given list (throws an exception in the empty case). |
|
abstract Ret |
forEmpty()
Handle an empty list |
|
abstract Ret |
forNonempty(T first,
ConsList<? extends T> rest)
Handle a nonempty list |
|
static
|
map(Lambda<? super S,? extends T> lambda)
Produces a new list by applying the given lambda to each of a list's elements |
|
static
|
rest()
Attempt to access the rest of the given list (throws an exception in the empty case). |
|
static
|
reverse()
Reverses the order of the elements in a list |
|
Ret |
value(ConsList<? extends T> list)
Invoke list.apply(this) |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ConsVisitor()
| Method Detail |
|---|
public abstract Ret forEmpty()
public abstract Ret forNonempty(T first,
ConsList<? extends T> rest)
public Ret value(ConsList<? extends T> list)
list.apply(this)
value in interface Lambda<ConsList<? extends T>,Ret>public static final <T> ConsVisitor<T,T> first()
public static final <T> ConsVisitor<T,ConsList<? extends T>> rest()
public static <T> ConsVisitor<T,ConsList<? extends T>> reverse()
public static <T> ConsVisitor<T,ConsList<? extends T>> append(ConsList<? extends T> rest)
public static <T> ConsVisitor<T,ConsList<T>> filter(Predicate<? super T> pred)
public static <S,T> ConsVisitor<S,ConsList<T>> map(Lambda<? super S,? extends T> lambda)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||