logo       
Google Custom Search
    AddThis Social Bookmark Button
-->

Re: Map with set operations over the keys: msg#00009

Subject: Re: Map with set operations over the keys
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




-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20


<Prev in Thread] Current Thread [Next in Thread>