Overlap algorithm for dates and segments

Many times when we are programming , we repeat the same calculations several times, and not in the most efficient way. This is an example, the calculation of the overlaping between dates, times or segments.

I think that this schema illustrates really well the trick, and the most efficient (reasoned) solution:

overlap_algorithm

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>