insertSet 4 (Data.Set.fromList [5, 3]) == fromList (3 :| [4, 5]) insertSet 4 Data.Set.empty == singleton 4 "c"
insertSetMin 7 (Data.Set.fromList [5, 3]) == fromList (3 :| [5, 7]) valid (insertSetMin 7 (Data.Set.fromList [5, 3])) == True valid (insertSetMin 2 (Data.Set.fromList [5, 3])) == False valid (insertSetMin 5 (Data.Set.fromList [5, 3])) == False
insertSetMin 2 (Data.Set.fromList [5, 3]) == fromList (2 :| [3, 5]) valid (insertSetMin 2 (Data.Set.fromList [5, 3])) == True valid (insertSetMin 7 (Data.Set.fromList [5, 3])) == False valid (insertSetMin 3 (Data.Set.fromList [5, 3])) == False
>>> 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>