org.zedlib
Interface Function

All Superinterfaces:
Collection, Relation, Set, Set
All Known Subinterfaces:
Bag, Sequence
All Known Implementing Classes:
HashBag, HashFun, HashSeq

public interface Function
extends Relation

This class provides similar functionality to java.util.Map, however, it is properly descended from a Set (org.zedlib.Set, hence implements the java.util.Set interface). It does not implement the java.util.Map interface because of conflicts between the java.util.Map and java.util.Set interfaces. If X and Y are sets, X → Y is the set of partial functions from X to Y. These are relations which relate each member x of X to at most one member of Y.

Author:
Brad Long

Method Summary
 boolean containsKey(Object key)
          An alternative for domain().contains(key).
 boolean containsValue(Object value)
          An alternative for range().contains(value).
 Maplet getMaplet(Object key)
          Returns the maplet that a given key participates in.
 Object put(Maplet m)
          Adds a maplet to this function.
 
Methods inherited from interface org.zedlib.Relation
add, add, addAll, composition, domain, domainAntiRestriction, domainRestriction, image, inverse, isFunction, isInjection, isReflexive, override, range, rangeAntiRestriction, rangeRestriction, transitiveClosure
 
Methods inherited from interface org.zedlib.Set
cartesianProduct, difference, identity, intersection, isSubsetOf, isSupersetOf, union
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

put

public Object put(Maplet m)
Adds a maplet to this function. Existing maplets with the same x in (x,y) are overwritten with the given maplet.

Parameters:
m - the maplet to add to the function
Returns:
the object, y in (x,y), that was replaced or null if there was no maplet having a key of x in the function.

getMaplet

public Maplet getMaplet(Object key)
Returns the maplet that a given key participates in.

Parameters:
key - the key (x) with which to obtain its corresponding (y) value
Returns:
the maplet that the given key participates in, or null if no maplet exists with the given key.

containsValue

public boolean containsValue(Object value)
An alternative for range().contains(value).

Parameters:
value - the object to check for existence in the range of this function
Returns:
true if a given value, y, is contained in the range of this function

containsKey

public boolean containsKey(Object key)
An alternative for domain().contains(key).

Parameters:
key - the object to check for existence in the domain of this function
Returns:
true if a given value, x, is contained in the domain of this function


Copyright © 2006 Brad Long. All Rights Reserved.