name.panitz.eliza
Class Map<a,b>
java.lang.Object
name.panitz.eliza.LiImpl<Pair<a,b>>
name.panitz.eliza.Map<a,b>
- All Implemented Interfaces:
- Li<Pair<a,b>>
public class Map<a,b>
- extends LiImpl<Pair<a,b>>
Simple implementation of a map as a list of pairs.
Method Summary |
b |
lookup(a key,
b defaultVal)
Returns the associated value for some key in the map. |
static
|
map(c key,
d val,
Map<c,d> m)
|
Map<a,b> |
tail()
Returns the list after the first element has been skipped. |
Methods inherited from class name.panitz.eliza.LiImpl |
append, concat, cons, drop, empty, filter, head, isEmpty, length, reverse, rotate, tails, toString, unwords |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Map
public Map(Pair<a,b> hd,
Map<a,b> tl)
Map
public Map()
tail
public Map<a,b> tail()
- Description copied from interface:
Li
- Returns the list after the first element has been skipped.
- Specified by:
tail
in interface Li<Pair<a,b>>
- Overrides:
tail
in class LiImpl<Pair<a,b>>
- Returns:
- the tail (rest) of the list, which follows first element.
lookup
public b lookup(a key,
b defaultVal)
- Returns the associated value for some key in the map.
If the key is not found in the map the default value is returned.
- Parameters:
key
- the key an entry is searched for in the map.defaultVal
- the value which is returned if the key is not found.
- Returns:
- the result of the map.
map
public static <c,d> Map<c,d> map(c key,
d val,
Map<c,d> m)