I am trying to develop some codes of image processing.
I want to design a different API which could support different type,
like int, double, float, char and others without the help of dynamic polymorphism
Because I find out that when you deal with image processing, dynamic polymorphism
would slow you down, use primitive types like int or char is the fastest
solution, but it is very inconvenient when I want to design different API according
to those types.
Besides, I want to do something like this without the burden of dynamic polymorphism
public static void convert_color(
final int[] sp, final int[] dp,
final int Xres, final int Yres,
Strategy strategy)
{
\\....
}
Some algorithms would suffer from the performance penalty of strategy(dynamic polymorphism)
I need to copy and paste just because the strategy are differents.
It is very difficult to design a high performance and flexibility image processing with
my current level, do you have a better solution to gain performance and flexibility?
I suggest you at how Trove4j solves this problem as it generates collections for primitives. You can also use their collections.
I would start with a “super type” e.g.
doubleand optimise the code where you find it makes a difference.