From: Martin J. <mar...@em...> - 2005-06-06 21:05:33
|
On Mon, 6 Jun 2005, 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. > >>> > >> > >>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 ... I concur. Maybe we can use another name than "merge", but I like this use of exceptions. Here the term "exception" is really appropriate since it's an exception to the mathematical meaning of union (or intersection). Martin -- Martin Jambon, PhD http://martin.jambon.free.fr |