From: fva <fv...@ts...> - 2005-06-06 10:28:39
|
Hello Christophe Raffalli wrote: >Nicolas Cannasse wrote: > > >>>>After a second though I think it's little overweighted to make the user >>>>specify a merge function. Why not simply specify that in such cases, the >>>>item of the first map is selected ? That seems more reasonable. >>>> >>>> I like the idea of the merge function parameter... This makes sense when you do not rely on the identity to provide for equality of representations in the base set. >>>No, you can for instance implement multiset as map to natural ... and >>>the merge function is then addition. >>> >>>Your merge function should even raise the exception Remove when you want >>>to say that the result should be removed from the map ... (For insance, >>>if you have Map to integer and want to say that 0 should be removed from >>>the map). >>> >>> >>I would say it's bad API design to use a "merge" function in order to remove >>elements. >>A more specific function should be provided. >> >> > >I do not think so. When your merge gives accidentally 0, and the value >should be removed, you do not want to scan the map once more to remove >the zero ... > > In my opinion, this depends on the representation (i.e. eventually the semantics): 1) If you are representing the *support* i.e. those elements *not* mapping to the null element (whatever that means) you should remove those elements the merge operationg of which map to null 2) If you are representing the whole map/set/many-valued set whatever in its entirety, you should keep the merged value, whatever the result. But again, this is just an opinion... Regards, F. Valverde |