It would be very similar to how we discussed either using Comparable objects or providing a Comparator. So, you'd either use Summable (or whatever it's called) objects or allow the user to provide a BinaryOperation object (that matches the type of course):
public interface BinaryOperation<T> { public T execute(T operand1, T operand2); } Perhaps we can come up with an interface that combines the two aspects. I'm trying to think of mathematically what that would be called. By the way, what do you need to know "HasZero"? A sum operation has to have a "zero", doesn't it? Well, I guess I'm considering weights to be a "group" in the abstract algebra sense. If so, then they'd have to follow the properties of a group and thus there would exist an identity ("zero" for sum operation) element. On Wed, Dec 14, 2011 at 7:26 AM, Claudio Squarcella <squar...@dia.uniroma3.it> wrote: > Hi, > > > On 14/12/2011 12:34, James Carman wrote: >> >> I don't like the idea of pushing the adding, comparing, etc. into the >> weights. I like the idea of having operations external to the weights >> that take care of that stuff. > > > I would be happy with non-polluted weights, so I am with you. But I am not > quite sure how to translate that into a good implementation. Do you have an > idea to share? > > Thanks, > > Claudio > > -- > Claudio Squarcella > PhD student at Roma Tre University > E-mail address: squar...@dia.uniroma3.it > Phone: +39-06-57333215 > Fax: +39-06-57333612 > http://www.dia.uniroma3.it/~squarcel > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org > For additional commands, e-mail: dev-h...@commons.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org