Monday 15 April 2013

generics - Java: "implements operator?" -


I have some functions that contain a lot of calculated content using all calculation operators [], *, /, + and - Are done by If there are eyes and loops and tests, those same functions can be "used in any way" which implements those operators, e.g. Double, float, int, taller etc. For reasons of performance, I just use basic types. Is there any way to normalize it?

In addition to this, I think floats and injections should not be doubled and dipped in double. I want to calc in the integer integer, in float on float and in doubles, I only 3 Multiply does not want to write the same code, which just differs in the type used. For example, suppose you have

  public double doSomething (double A, double B) {return A * B + 1; }   

Of course, the actual FN does nothing more than this.

I think a move will be something like this. Public T DoSomething (TA, TB) {back staticAdd (staticMul (A, B), 1); }

one ?? | And define basic functions for static functions for all used types. But as they are not noticed, they will add another FN-call.

Is there any way in Java, like & lt; T applies, applies -> & gt; Recommendations for defining methods like staticAdd are not as bad as you think before. What the hotspot will do for you (when it's in the mood). If you define for those types of actions that you are worried, then you can achieve good performance.

He said, you are still going to tackle autoboxing, because you can not normalize the methods in the oldest. If performance is really important, you can get trapped in writing several method signing. Notice that, it is rumored that the old version may be in future versions of Java / JVM. Of course, the penalty is not zero to deal with the wrapped type, but it is negligible in many applications.

No comments:

Post a Comment