Start with an array of dots (-Inf, Inf) and (Inf, -Inf)
The order of the elements in the array relative to the rule below
for (x,y) and (t,z) if x<t (x,t) is before (t,z) if x=t and y>z then (x,t) is before (t,z)
If you want to insert an element, find the element with the highest order that is before the inserted element and name it EBefore. Also find the element with the lowest order that is after the inserted element and calls it EAfter. You can use binary search when searching for these two elements.
If the vector product
EInserted x (EAfter - EBefore) > 0
delete all elements between EBefore and EAfter and insert EInserted between them. If the product is negative, do not add the item.
source share