xtc.util
Class Function

java.lang.Object
  extended by xtc.util.Function

public class Function
extends java.lang.Object

Function definitions.

Version:
$Revision: 1.5 $
Author:
Laune Harris, Robert Grimm

Nested Class Summary
static interface Function.F0<R>
          A function with no arguments.
static interface Function.F1<R,A>
          A function with one argument.
static interface Function.F10<R,A,B,C,D,E,F,G,H,I>
          A function with ten arguments.
static interface Function.F11<R,A,B,C,D,E,F,G,H,I,J>
          A function with eleven arguments.
static interface Function.F12<R,A,B,C,D,E,F,G,H,I,J,K>
          A function with twelve arguments.
static interface Function.F13<R,A,B,C,D,E,F,G,H,I,J,K,L>
          A function with thirteen arguments.
static interface Function.F14<R,A,B,C,D,E,F,G,H,I,J,K,L,M>
          A function with fourteen arguments.
static interface Function.F15<R,A,B,C,D,E,F,G,H,I,J,K,L,M,N>
          A function with fifteen arguments.
static interface Function.F2<R,A,B>
          A function with two arguments.
static interface Function.F3<R,A,B,C>
          A function with three arguments.
static interface Function.F4<R,A,B,C,D>
          A function with four arguments.
static interface Function.F5<R,A,B,C,D,E>
          A function with five arguments.
static interface Function.F6<R,A,B,C,D,E,F>
          A function with six arguments.
static interface Function.F7<R,A,B,C,D,E,F,G>
          A function with seven arguments.
static interface Function.F8<R,A,B,C,D,E,F,G,H>
          A function with eight arguments.
static interface Function.F9<R,A,B,C,D,E,F,G,H>
          A function with nine arguments.
 
Method Summary
static
<T,U> U
foldl(Function.F2<U,? super T,U> function, U seed, Pair<T> list)
          Fold the specified list with the specified function.
static
<T,U> void
iterate(Function.F1<U,? super T> function, Pair<T> list)
          Iterate the specified function over the specified list.
static
<T,U> Pair<U>
map(Function.F1<U,? super T> function, Pair<T> list)
          Map the specified function over the specified list.
static
<T> boolean
matchesAll(Function.F1<java.lang.Boolean,? super T> pred, Pair<T> list)
          Determine whether the specified list contains only elements matching the specified predicate.
static
<T> boolean
matchesOne(Function.F1<java.lang.Boolean,? super T> pred, Pair<T> list)
          Determine whether the specified list contains an element matching the specified predicate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

iterate

public static <T,U> void iterate(Function.F1<U,? super T> function,
                                 Pair<T> list)
Iterate the specified function over the specified list.

Parameters:
function - The function.
list - The list.

map

public static <T,U> Pair<U> map(Function.F1<U,? super T> function,
                                Pair<T> list)
Map the specified function over the specified list. Note that the implementation does not recurse.

Parameters:
function - The function.
list - The list.
Returns:
The result of mapping the function.

foldl

public static <T,U> U foldl(Function.F2<U,? super T,U> function,
                            U seed,
                            Pair<T> list)
Fold the specified list with the specified function. This method successively applies the specified function to each of the list's elements and a running result, which is initialized to the specified seed.

Parameters:
function - The function.
seed - The seed value.
list - The list.
Returns:
The folded value.

matchesAll

public static <T> boolean matchesAll(Function.F1<java.lang.Boolean,? super T> pred,
                                     Pair<T> list)
Determine whether the specified list contains only elements matching the specified predicate.

Parameters:
pred - The predicate.
list - The list.
Returns:
true if the list contains only matching elements.

matchesOne

public static <T> boolean matchesOne(Function.F1<java.lang.Boolean,? super T> pred,
                                     Pair<T> list)
Determine whether the specified list contains an element matching the specified predicate.

Parameters:
pred - The predicate.
list - The list.
Returns:
true if the list contains at least one matching element.


Copyright © 2012. All Rights Reserved.