I'm looking for a good / efficient algorithm to compare classes of driver licences (or any type of similar objects) and their dates, so that they do not overlap and come in certain order.
eg. We have G1, G2, G, M, etc.
I need to make sure all instances of G1 do not overlap, G1 comes before G2 and does not overlap, and G comes after both, and M is unrelated (there can also be multiple instances of each type, in which case they must not overlap either).
I'm looking to do this without a monster class of if/else statements that no one can ever read.