Home | Libraries | People | FAQ | More |
By definition a map is set of pairs. So we would expect maps to obey the
same laws that are valid for sets. Yet the semantics of the itl's
maps may be a different one, because of it's aggregating facilities, where
the aggregating combiner operations are passed to combine the map's associated
values. It turns out, that the aggregation on overlap principle induces semantical
properties to itl maps in such a way, that the set of equations that are
valid will depend on the semantics of the type CodomainT
of the map's associated values.
This is less magical as it might seem at first glance. If, for instance,
we instantiate an interval_map
to collect and concatenate std::strings
associated to intervals,
interval_map<int,std::string> cat_map; cat_map += make_pair(interval<int>::rightopen(1,5),std::string("Hello")); cat_map += make_pair(interval<int>::rightopen(3,7),std::string(" World")); cout << "cat_map: " << cat_map << endl;
we won't be able to apply operator
-=
// This will not compile because string::operator -= is missing. cat_map -= make_pair(interval<int>::rightopen(3,7),std::string(" World"));
because, as std::sting does not implement -=
itself, this won't compile. So all laws,
that rely on operator -=
or -
not only will not be valid
they can not even be stated. This reduces the set of laws that can be valid
for a richer CodomainT
type
to a smaller set of laws and thus to a less restricted semantics.
Currently we have investigated and validated two major instantiations of itl::Maps,
both of which seem to have many interesting use cases for practical applications. The semantics associated with the term Numbers is a commutative monoid for unsigned numbers and a commutative or abelian group for signed numbers. From a practical point of view we can think of numbers as counting or quantifying the key values of the map.
Itl Maps of Sets or
Collectors are models
of concept Set
. This implies
that all laws that have been stated as a semantics for itl::Sets
in the previous chapter also hold for Maps
of Sets
.
Itl Maps of Numbers
or Quantifiers on the
contrary are not models of concept Set
.
But there is a substantial intersection of laws that apply both for Collectors
and Quantifiers
.
Kind of Map |
Alias |
Behavior |
---|---|---|
Maps of Sets |
Collector |
Collects items for key values |
Maps of Numbers |
Quantifier |
Counts or quantifies the key values |
In the next two sections the law based semantics of Collectors and Quantifiers will be described in more detail.