com.myjavatools.lib.foundation
Class FunctionalMap<Domain,Codomain>

java.lang.Object
  extended by java.util.AbstractMap<Domain,Codomain>
      extended by com.myjavatools.lib.foundation.FunctionalMap<Domain,Codomain>
All Implemented Interfaces:
java.util.Map<Domain,Codomain>

public class FunctionalMap<Domain,Codomain>
extends java.util.AbstractMap<Domain,Codomain>

FunctionalMap is a helper class that implements Map which maps keys from Domain set to values of Domain (a.k.a. Range) that are values of function: Domain -> Codomain. Note that this class does not take any additional memory; lazy evaluation uses only the keyset provided

Since:
5.0
Version:
5.0, 11/15/04
See Also:
Function, Maps, Map

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
java.util.Map.Entry<K,V>
 
Constructor Summary
FunctionalMap(Function<Domain,Codomain> function, java.util.Set<Domain> domain)
          constructor
 
Method Summary
 boolean containsKey(java.lang.Object x)
          Returns true if this map contains a mapping for the specified key.
 java.util.Set<java.util.Map.Entry<Domain,Codomain>> entrySet()
          Returns a set view of the mappings contained in this map.
 
Methods inherited from class java.util.AbstractMap
clear, clone, containsValue, equals, get, hashCode, isEmpty, keySet, put, putAll, remove, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FunctionalMap

public FunctionalMap(Function<Domain,Codomain> function,
                     java.util.Set<Domain> domain)
constructor

Parameters:
function - Function<Domain,Codomain> the function that maps keys to values
domain - Set<Domain> key set
Method Detail

containsKey

public boolean containsKey(java.lang.Object x)
Returns true if this map contains a mapping for the specified key.

Specified by:
containsKey in interface java.util.Map<Domain,Codomain>
Overrides:
containsKey in class java.util.AbstractMap<Domain,Codomain>
Parameters:
x - key whose presence in this map is to be tested.
Returns:
true if this map contains a mapping for the specified key.

entrySet

public java.util.Set<java.util.Map.Entry<Domain,Codomain>> entrySet()
Returns a set view of the mappings contained in this map.

Specified by:
entrySet in interface java.util.Map<Domain,Codomain>
Specified by:
entrySet in class java.util.AbstractMap<Domain,Codomain>
Returns:
a set view of the mappings contained in this map. Implementation note. Actually no large object is created; the returned set is a lazy evaluation implementation of Set.