Wednesday, 15 January 2014

java - How should I store a two column table with duplicated first column entries? -


There are 72 paths in my program (numbered from 1 to 72) In the program, I need to retrieve the path, And then check the ownership of these two routes. Path 2 ranges from adjacent to 4. For example, Path 1 has adjacent paths 2 and 7; Whereas path adjacent to path 13 is 8, 12, 14, 21. These path relations are continuous.

I would like to write a method path.getAdjacent (int pathNum) a int [] will return which contains all adjacent paths. In this way I can make a loop which checks the owners for each adjacent path.

How should I store and access path relationship data so that this method can be retrieved efficiently from path.

Dwight answered my question:

Use a map & lt; Integer, Arrayist & lt; Integer & gt; & Gt;


No comments:

Post a Comment