jfun.parsec
Class Maps

java.lang.Object
  extended by jfun.parsec.Maps

public final class Maps
extends java.lang.Object

This class provides some standard Map implementations.

Author:
Ben Yu Nov 19, 2004

Constructor Summary
Maps()
           
 
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.
static
<R> Unary<R>
id(java.lang.Class<R> type)
          Returns an identity map.
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<java.lang.Object[]> idn()
          Returns an identity map.
static
<From,To> Map<From,To>
jmap(java.util.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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Maps

public Maps()
Method Detail

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(java.lang.Class<R> type)
Returns an identity map. map a = a.

Parameters:
type - the class literal for the type parameter.
Returns:
the Map instance.

idn

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

Returns:
the Mapn instance.

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.

jmap

public static <From,To> Map<From,To> jmap(java.util.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.

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.