some time ago I've read a paper that advised to store intervals on
discrete
values in the format [a;b[. One starts with the first element and finishes
with one past the last one.
There are lots of reasons. Here is one that I personally consider to be
conclusive.
If you represent a range by its first and last elements (symmetric ranges),
then an empty range is an anomaly: You need to find way to represent not
just one but two distinct positions that do not correspond to any element.
If you represent a range by its first and one past its last elements
(asymmetric), then you always need a way to represent a position that
doesn't correspond to any element, but the difficulty in doing so is the
same regardless of the number of elements.
Moreover, assymetric ranges have the nice property that begin<=end at all
times, and begin==end if and only if the range is empty. With symmetric
ranges, begin==end if and only if the range has precisely one element, and
begin>end if the range is empty. This latter behavior is much less useful
if you are using iterators that support only == and != comparisons.
If this argument doesn't convince you, here are some others:
If you are using integer indices, you can use unsigned values to represent
an asymmetric range. You need signed values to represent a symmetric
range--to cater to the specific case of [0,-1] which is needed to represent
an empty range.
If you are using pointers to array elements, you have a problem in C or C++
representing an empty symmetric range because you are not generally allowed
to compute the address that precedes an array.