|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.rice.cs.plt.recur.RecursionStack4<T1,T2,T3,T4>
public class RecursionStack4<T1,T2,T3,T4>
A stack used to store the arguments of a recursive invocation in order to prevent infinite recursion. By checking that the given arguments have not been used previously before recurring, a client can prevent infinite recursion in some circumstances (such as when traversing an infinite, immutable data structure).
The client may either choose to explicity check for containment, push(T1, T2, T3, T4) the
arguments, recur, and then pop(T1, T2, T3, T4), or invoke one of a variety of lambda-based
methods that perform these bookkeeping tasks automatically. In the latter case, when an
exception occurs between a push and a matching pop, the pop is
guaranteed to execute before the exception propagates upward. Thus, clients who do not
directly invoke push(T1, T2, T3, T4) and pop(T1, T2, T3, T4) may assume that the stack is always in a
consistent state.
PrecomputedRecursionStack4,
RecursionStack,
RecursionStack2,
RecursionStack3| Constructor Summary | |
|---|---|
RecursionStack4()
Create an empty recursion stack with an IdentityQuad factory |
|
RecursionStack4(Lambda4<? super T1,? super T2,? super T3,? super T4,? extends Quad<T1,T2,T3,T4>> quadFactory)
Create an empty recursion stack with the given Quad factory |
|
| Method Summary | ||
|---|---|---|
|
apply(Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> lambda,
Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4)
If the given arguments are not on the stack, evaluate lambda with the arguments;
otherwise, evaluate infiniteCase. |
|
|
apply(Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> lambda,
Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4,
int threshold)
If less than threshold instances of the given arguments are on the stack,
evaluate lambda with the arguments; otherwise, evaluate infiniteCase. |
|
|
apply(Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> lambda,
R infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4)
Evaluate the given lambda with the given arguments, unless the arguments are already on the stack; push the arguments onto the stack during lambda evaluation |
|
|
apply(Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> lambda,
R infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4,
int threshold)
Evaluate the given lambda with the given arguments, unless threshold instances
of the arguments are already on the stack; push the arguments onto the stack
during lambda evaluation |
|
|
apply(Thunk<? extends R> thunk,
R infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
Evaluate the given thunk, unless the given arguments are already on the stack; push the arguments onto the stack during thunk evaluation |
|
|
apply(Thunk<? extends R> thunk,
R infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4,
int threshold)
Evaluate the given thunk, unless threshold instances of the given arguments are
already on the stack; push the arguments onto the stack during thunk evaluation |
|
|
apply(Thunk<? extends R> thunk,
Thunk<? extends R> infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
If the given arguments are not on the stack, evaluate thunk; otherwise, evaluate
infiniteCase. |
|
|
apply(Thunk<? extends R> thunk,
Thunk<? extends R> infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4,
int threshold)
If less than threshold instances of the given arguments are on the stack,
evaluate thunk; otherwise, evaluate infiniteCase. |
|
boolean |
contains(T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
|
|
boolean |
contains(T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4,
int threshold)
|
|
boolean |
isEmpty()
|
|
static
|
make()
Call the constructor (allows the type arguments to be inferred) |
|
static
|
make(Lambda4<? super T1,? super T2,? super T3,? super T4,? extends Quad<T1,T2,T3,T4>> quadFactory)
Call the constructor (allows the type arguments to be inferred) |
|
void |
pop(T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
Remove the given arguments from the top of the stack |
|
void |
push(T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
Add the given arguments to the top of the stack |
|
|
run(Runnable4<? super V1,? super V2,? super V3,? super V4> r,
Runnable4<? super V1,? super V2,? super V3,? super V4> infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4)
If the given arguments are not on the stack, run r with argument the arguments;
otherwise, run infiniteCase. |
|
|
run(Runnable4<? super V1,? super V2,? super V3,? super V4> r,
Runnable4<? super V1,? super V2,? super V3,? super V4> infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4,
int threshold)
If less than threshold instances of the given arguments are on the stack,
run r with the arguments; otherwise, run infiniteCase. |
|
|
run(Runnable4<? super V1,? super V2,? super V3,? super V4> r,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4)
Run the given runnable with the given arguments, unless the arguments are already on the stack; push the arguments onto the stack during runnable execution |
|
|
run(Runnable4<? super V1,? super V2,? super V3,? super V4> r,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4,
int threshold)
Run the given runnable with the given arguments, unless threshold instances
of the arguments are already on the stack; push the arguments onto the stack during
runnable execution |
|
void |
run(Runnable r,
Runnable infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
If the given arguments are not on the stack, run r; otherwise, run
infiniteCase. |
|
void |
run(Runnable r,
Runnable infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4,
int threshold)
If less than threshold instances of the given arguments are on the stack, run
r; otherwise, run infiniteCase. |
|
void |
run(Runnable r,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
Run the given runnable, unless the given arguments are already on the stack; push the arguments onto the stack during runnable execution |
|
void |
run(Runnable r,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4,
int threshold)
Run the given runnable, unless threshold instances of the given arguments are
already on the stack; push the arguments onto the stack during runnable execution |
|
int |
size()
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RecursionStack4()
IdentityQuad factory
public RecursionStack4(Lambda4<? super T1,? super T2,? super T3,? super T4,? extends Quad<T1,T2,T3,T4>> quadFactory)
Quad factory
quadFactory - A lambda used to produce a quad for values placed on the
stack. This provides clients with control over the method used
to determine if a value has been seen previously.| Method Detail |
|---|
public boolean contains(T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
true iff a set of values identical (according to ==) to the
given arguments is currently on the stack
public boolean contains(T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4,
int threshold)
true iff at least threshold sets of values identical
(according to ==) to the given arguments are currently on the stack
public void push(T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
public void pop(T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
IllegalArgumentException - If the given arguments are not at the top of the stackpublic int size()
public boolean isEmpty()
true iff the stack is currently empty
public void run(Runnable r,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
public void run(Runnable r,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4,
int threshold)
threshold instances of the given arguments are
already on the stack; push the arguments onto the stack during runnable execution
public void run(Runnable r,
Runnable infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
r; otherwise, run
infiniteCase. In either case, push the arguments onto the stack during
runnable execution.
public void run(Runnable r,
Runnable infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4,
int threshold)
threshold instances of the given arguments are on the stack, run
r; otherwise, run infiniteCase. In either case, push the
arguments onto the stack during runnable execution.
public <V1 extends T1,V2 extends T2,V3 extends T3,V4 extends T4> void run(Runnable4<? super V1,? super V2,? super V3,? super V4> r,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4)
public <V1 extends T1,V2 extends T2,V3 extends T3,V4 extends T4> void run(Runnable4<? super V1,? super V2,? super V3,? super V4> r,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4,
int threshold)
threshold instances
of the arguments are already on the stack; push the arguments onto the stack during
runnable execution
public <V1 extends T1,V2 extends T2,V3 extends T3,V4 extends T4> void run(Runnable4<? super V1,? super V2,? super V3,? super V4> r,
Runnable4<? super V1,? super V2,? super V3,? super V4> infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4)
r with argument the arguments;
otherwise, run infiniteCase. In either case, push the arguments onto the
stack during runnable execution.
public <V1 extends T1,V2 extends T2,V3 extends T3,V4 extends T4> void run(Runnable4<? super V1,? super V2,? super V3,? super V4> r,
Runnable4<? super V1,? super V2,? super V3,? super V4> infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4,
int threshold)
threshold instances of the given arguments are on the stack,
run r with the arguments; otherwise, run infiniteCase. In either case,
push the arguments onto the stack during runnable execution.
public <R> R apply(Thunk<? extends R> thunk,
R infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
thunk, or infiniteCase
public <R> R apply(Thunk<? extends R> thunk,
R infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4,
int threshold)
threshold instances of the given arguments are
already on the stack; push the arguments onto the stack during thunk evaluation
thunk, or infiniteCase
public <R> R apply(Thunk<? extends R> thunk,
Thunk<? extends R> infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4)
thunk; otherwise, evaluate
infiniteCase. In either case, push the arguments onto the stack during
thunk evaluation.
thunk, or the value of infiniteCase
public <R> R apply(Thunk<? extends R> thunk,
Thunk<? extends R> infiniteCase,
T1 arg1,
T2 arg2,
T3 arg3,
T4 arg4,
int threshold)
threshold instances of the given arguments are on the stack,
evaluate thunk; otherwise, evaluate infiniteCase. In either case, push
the arguments onto the stack during thunk evaluation.
thunk, or the value of infiniteCase
public <V1 extends T1,V2 extends T2,V3 extends T3,V4 extends T4,R> R apply(Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> lambda,
R infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4)
lambda, or infiniteCase
public <V1 extends T1,V2 extends T2,V3 extends T3,V4 extends T4,R> R apply(Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> lambda,
R infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4,
int threshold)
threshold instances
of the arguments are already on the stack; push the arguments onto the stack
during lambda evaluation
lambda, or infiniteCase
public <V1 extends T1,V2 extends T2,V3 extends T3,V4 extends T4,R> R apply(Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> lambda,
Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4)
lambda with the arguments;
otherwise, evaluate infiniteCase. In either case, push the arguments onto the
stack during lambda evaluation.
lambda, or the value of infiniteCase
public <V1 extends T1,V2 extends T2,V3 extends T3,V4 extends T4,R> R apply(Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> lambda,
Lambda4<? super V1,? super V2,? super V3,? super V4,? extends R> infiniteCase,
V1 arg1,
V2 arg2,
V3 arg3,
V4 arg4,
int threshold)
threshold instances of the given arguments are on the stack,
evaluate lambda with the arguments; otherwise, evaluate infiniteCase.
In either case, push the arguments onto the stack during lambda evaluation.
lambda, or the value of infiniteCasepublic static <T1,T2,T3,T4> RecursionStack4<T1,T2,T3,T4> make()
public static <T1,T2,T3,T4> RecursionStack4<T1,T2,T3,T4> make(Lambda4<? super T1,? super T2,? super T3,? super T4,? extends Quad<T1,T2,T3,T4>> quadFactory)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||