...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
On the fundamental aspect all interval_sets
are models of a concept Set
.
The Set
concept of the Interval
Template Library refers to the mathematical notion of a set.
Function |
Variant |
implemented as |
---|---|---|
empty set |
|
|
subset relation |
|
|
equality |
|
|
set union |
inplace |
|
|
|
|
set difference |
inplace |
|
|
|
|
set intersection |
inplace |
|
|
|
|
Equality on Sets
is not implemented
as operator ==
,
because operator ==
is used for the stronger lexicographical equality on segments, that takes
the segmentation of elements into account.
Being models of concept Set
,
std::set
and all interval_sets
implement these operations and obey the associated laws on Sets
. See e.g. an
algebra of sets here.
An interval
is considered
to be a set of elements as well. With respect to the Set
concept presented above interval
implements the concept only partially. The reason for that is that addition
and subtraction can not be defined on intervals
.
Two intervals [1,2]
and [4,5]
are not addable to a single
new interval
. In other
words intervals
are incomplete
w.r.t. union and difference. Interval_sets
can be defined as the completion
of intervals for the union and difference operations.
When we claim that addition or subtraction can not be defined on intervals, we are not considering things like e.g. interval arithmetics, where these operations can be defined, but with a different semantics.
On the fundamental aspect icl::map
and all interval_maps
are models of a concept Map
.
Since a map
is a set of pairs
, we try to design the Map
concept in accordance to the Set
concept above.
Function |
Variant |
implemented as |
---|---|---|
empty map |
|
|
subset relation |
|
|
equality |
|
|
map union |
inplace |
|
|
|
|
map difference |
inplace |
|
|
|
|
map intersection |
inplace |
|
|
|
|
As one can see, on the abstract kernel the signatures of the icl's Set
and Map
concepts are identical, except for the typename. While signatures are identical
The sets of valid laws are different, which will be described in more detail
in the sections on the semantics
of icl Sets and Maps.
These semantic differences are mainly based on the implementation of the
pivotal member functions add
and subtract
for elements
and intervals that again serve for implementing operator
+=
and operator
-=
.