insert module:Data.Set package:hgeometry-combinatorial

Inserts an element into the set, assuming that the set is ordered by the given order.
>>> insertBy cmpS (S "ccc") $ fromListBy cmpS [S "a" , S "bb" , S "dddd"]
fromList [S "a",S "bb",S "ccc",S "dddd"]
When trying to insert an element that equals an element already in the set (according to the given comparator), this function replaces the old element by the new one:
>>> insertBy cmpS (S "cc") $ fromListBy cmpS [S "a" , S "bb" , S "dddd"]
fromList [S "a",S "cc",S "dddd"]
running time: <math>