I'm implementing an algorithm for pathfinding that is a variant of A* (HPA*) but with a triangulated search space. I've been making a Java application and have written a good amount of code, but I recently found a C++ library that already takes care of the triangulations for the project. I have several options but I'm not sure what I should do: convert the library to Java or integrate the C++ code into my Java library. I could also rewrite my code in C++ but I'm not very familiar with the language.

This application tests the performance of an algorithm for a paper I'm writing so it doesn't need to be portable. What do you think my best option is?

有帮助吗?

解决方案

If you really want to call C++ code from Java, read up on the Java Native Interface (JNI) coding conventions.

But generally, unless you have an extremely good reason to cross languages, it's more trouble than it's worth. How complicated is the triangulation code? If it's less than a few hundred lines, I'd suggest reimplementing; if it's more than a few thousand, using a library may be justified but you should probably check whether there's a Java library available or if someone has already written the appropriate JNI glue code.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top