Package org.tweetyproject.commons.util
Class MapTools<E,F>
java.lang.Object
org.tweetyproject.commons.util.MapTools<E,F>
- Type Parameters:
E
- Domain class of the mapsF
- Range class of the maps
This class provides some utility functions for maps.
- Author:
- Matthias Thimm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionallBijections
(Collection<E> domain, Collection<F> range) Computes all bijections from E to F.Computes the complete set of maps from E to F such that the following condition holds.This methods computes all maps from domain to range.allMapsSingleSource
(Map<E, Set<F>> relations) Computes the complete set of maps from E to F such that the following condition holds.Combines all maps in singleMaps to one maps containing every assignment of each map in singleMaps.static boolean
isInjective
(Map<? extends Object, ? extends Object> map) Checks whether the given map is injective, i.e.
-
Constructor Details
-
MapTools
public MapTools()Constructor
-
-
Method Details
-
allMaps
Computes the complete set of maps from E to F such that the following condition holds. For every map "m" in the result the set m.keySet() is equal to the union of all sets S with S in relations.keySet() and each element "e" in m.keySet() is mapped to an element "f" such that "f" in relations.get(S) with "e" in S. For example the map:
{a,b} => {1,2}
{c,d} => {3}
{f} => {4,5}
yields the set of maps:
a=>1, b=>1, c=>3, d=>3, f=>4
a=>1, b=>1, c=>3, d=>3, f=>5
a=>1, b=>2, c=>3, d=>3, f=>4
a=>1, b=>2, c=>3, d=>3, f=>5
a=>2, b=>1, c=>3, d=>3, f=>4
a=>2, b=>1, c=>3, d=>3, f=>5
a=>2, b=>2, c=>3, d=>3, f=>4
a=>2, b=>2, c=>3, d=>3, f=>5- Parameters:
relations
- a map from sets of E to sets of F.- Returns:
- a set of maps from E to F.
-
allMapsSingleSource
Computes the complete set of maps from E to F such that the following condition holds. For every map "m" in the result the set m.keySet() is equal to relations.keySet() and each element "e" in m.keySet() is mapped to an element "f" such that "f" in relations.get(S) with "e" in S. For example the map:
a => {1,2}
b => {3}
c => {4,5}
yields the set of maps:
a=>1, b=>3, c=>4
a=>1, b=>3, c=>5
a=>2, b=>3, c=>4
a=>2, b=>3, c=>5- Parameters:
relations
- a map from sets of E to sets of F.- Returns:
- a set of maps from E to F.
-
allBijections
Computes all bijections from E to F. E and F have to be of the same cardinality.- Parameters:
domain
- some set.range
- some set.- Returns:
- all bijections from E to F.
-
allMaps
-
combine
Combines all maps in singleMaps to one maps containing every assignment of each map in singleMaps.- Parameters:
singleMaps
- the set of maps to be combined.- Returns:
- a single map.
- Throws:
IllegalArgumentException
- if one key is used in more than one map of singleMaps.
-
isInjective
-