jfun.parsec

Class Maps

public final class Maps extends Object

This class provides some standard Map implementations.

Author: Ben Yu Nov 19, 2004

Method Summary
static <x,V> Map<x,V>cnst(V v)
Creates a map that maps any object to the same object.
static <x> Unary<x>id()
Returns an identity map. map a = a.
static <R> Unary<R>id(Class<R> type)
Returns an identity map. map a = a.
static <A,B> Map2<A,B,Pair<A,B>>id2()
Create a Map2 object that stores the two objects into a Pair object.
static <A,B,C> Map3<A,B,C,Tuple3<A,B,C>>id3()
Create a Map3 object that stores the 3 objects into a Tuple3 object.
static <A,B,C,D> Map4<A,B,C,D,Tuple4<A,B,C,D>>id4()
Create a Map4 object that stores the 4 objects into a Tuple4 object.
static <A,B,C,D,E> Map5<A,B,C,D,E,Tuple5<A,B,C,D,E>>id5()
Create a Map5 object that stores the 5 objects into a Tuple5 object.
static Mapn<Object[]>idn()
Returns an identity map. map a = a.
static <From,To> Map<From,To>jmap(Map<From,To> m)
Adapts a java.util.Map to jfun.util.Map.
static <T> Map<Tok,T>toToken()
Transform a Tok object to the wrapped token object.

Method Detail

cnst

public static <x,V> Map<x,V> cnst(V v)
Creates a map that maps any object to the same object.

Parameters: v the object that is gonna be returned from the Map.

Returns: the Map instance.

id

public static <x> Unary<x> id()
Returns an identity map. map a = a.

Returns: the Map instance.

id

public static <R> Unary<R> id(Class<R> type)
Returns an identity map. map a = a.

Parameters: type the class literal for the type parameter.

Returns: the Map instance.

id2

public static <A,B> Map2<A,B,Pair<A,B>> id2()
Create a Map2 object that stores the two objects into a Pair object.

id3

public static <A,B,C> Map3<A,B,C,Tuple3<A,B,C>> id3()
Create a Map3 object that stores the 3 objects into a Tuple3 object.

id4

public static <A,B,C,D> Map4<A,B,C,D,Tuple4<A,B,C,D>> id4()
Create a Map4 object that stores the 4 objects into a Tuple4 object.

id5

public static <A,B,C,D,E> Map5<A,B,C,D,E,Tuple5<A,B,C,D,E>> id5()
Create a Map5 object that stores the 5 objects into a Tuple5 object.

idn

public static Mapn<Object[]> idn()
Returns an identity map. map a = a.

Returns: the Mapn instance.

jmap

public static <From,To> Map<From,To> jmap(Map<From,To> m)
Adapts a java.util.Map to jfun.util.Map.

Parameters: m the java.util.Map object.

Returns: the jfun.util.Map instance.

toToken

public static <T> Map<Tok,T> toToken()
Transform a Tok object to the wrapped token object.

Returns: the Map instance.