I am porting some C++ code over to Java that uses some heavy pointer arithmetic. My problem is the following:
There is a structure built as such that I have implemented as a class:
In the original C/C++ code I have the following assignments,
struct mst_edge
{
int u, v;
double w;
}
mst_edge * tree_edges = new mst_edge[size];
int node_l = tree_edges->u;
int node_r = tree_edges->v;
How is it possible to convert this code to java? The second block declares mst_edge as a C/C++ dynamic array. But in the third block of code it uses the tree_edges as a direct pointer.
What would the Java equivalent of this be, considering memory and references are handled directly by Java?
<code>tags can only be used for code that doesn't contain newlines. See How do I format my code blocks? for more info.tree_edgesas a pointer tomst_edgeand initializes it with an array allocated on the free store. It is emphatically not a C dynamic array; C doesn't havenew.