Orbital library

orbital.logic.functor
Class MutableFunction.TableFunction

java.lang.Object
  extended by orbital.logic.functor.MutableFunction.TableFunction
All Implemented Interfaces:
Function, Functor, MutableFunction
Enclosing interface:
MutableFunction

public static class MutableFunction.TableFunction
extends java.lang.Object
implements MutableFunction

A mutable function implemented as a tabular HashMap.

Author:
André Platzer
See Also:
HashMap

Nested Class Summary
 
Nested classes/interfaces inherited from interface orbital.logic.functor.MutableFunction
MutableFunction.TableFunction
 
Nested classes/interfaces inherited from interface orbital.logic.functor.Function
Function.Composite
 
Nested classes/interfaces inherited from interface orbital.logic.functor.Functor
Functor.Specification
 
Field Summary
 
Fields inherited from interface orbital.logic.functor.Function
callTypeDeclaration
 
Constructor Summary
MutableFunction.TableFunction()
          Create a table-based mutable function without lazy initialization.
MutableFunction.TableFunction(Function initialization)
           
MutableFunction.TableFunction(Function initialization, boolean cache)
          Create a table-based mutable function.
MutableFunction.TableFunction(java.util.Map map, Function initialization, boolean cache)
          Create a preinitialized table-based mutable function.
 
Method Summary
 java.lang.Object apply(java.lang.Object arg)
          Get the value of an argument.
 java.lang.Object clone()
           
 Function getInitialization()
          Get the initialization function h.
 java.lang.Object set(java.lang.Object arg, java.lang.Object value)
          Update the value at an argument.
 void setInitialization(Function initialization)
          Set the initialization function h to use.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface orbital.logic.functor.Functor
equals, hashCode, toString
 

Constructor Detail

MutableFunction.TableFunction

public MutableFunction.TableFunction(java.util.Map map,
                                     Function initialization,
                                     boolean cache)
Create a preinitialized table-based mutable function.

Parameters:
map - The tabular map in which values are stored.
initialization - The function h to use for implicit lazy initialization f(x) = h(x) for yet unknown arguments x. Use null to disable lazy initialization, leading to null being the value for yet unknown arguments.
cache - whether values lazy initialized via initialization should be cached in the hash map. Caching is important when no memory constraints are posed and the initialization function performs expensive calculation.

MutableFunction.TableFunction

public MutableFunction.TableFunction(Function initialization,
                                     boolean cache)
Create a table-based mutable function.

Parameters:
initialization - The function h to use for implicit lazy initialization f(x) = h(x) for yet unknown arguments x. Use null to disable lazy initialization, leading to null being the value for yet unknown arguments.
cache - whether values lazy initialized via initialization should be cached in the hash map. Caching is important when no memory constraints are posed and the initialization function performs expensive calculation.

MutableFunction.TableFunction

public MutableFunction.TableFunction(Function initialization)

MutableFunction.TableFunction

public MutableFunction.TableFunction()
Create a table-based mutable function without lazy initialization.

Method Detail

clone

public java.lang.Object clone()
Specified by:
clone in interface MutableFunction
Overrides:
clone in class java.lang.Object

getInitialization

public Function getInitialization()
Get the initialization function h.


setInitialization

public void setInitialization(Function initialization)
Set the initialization function h to use.

Parameters:
initialization - The function h to use for implicit lazy initialization f(x) = h(x) for yet unknown arguments x, from now on. Use null to disable lazy initialization, leading to null being the value for yet unknown arguments.

apply

public java.lang.Object apply(java.lang.Object arg)
Get the value of an argument.

Specified by:
apply in interface Function
Parameters:
arg - generic Object as argument
Returns:
f(x). Implicitly lazy initializing f(x) = h(x) for yet unknown arguments x.

set

public java.lang.Object set(java.lang.Object arg,
                            java.lang.Object value)
Update the value at an argument.

Specified by:
set in interface MutableFunction
Parameters:
arg - the argument x whose cost to update.
value - the new value f(x) to set for argument x.
Returns:
the old value f(arg) prior to updating the function.

Orbital library
1.3.0: 11 Apr 2009

Copyright © 1996-2009 André Platzer
All Rights Reserved.