svn-gvsig-desktop / trunk / extensions / extGraph / src / org / gvsig / graph / core / GlobalCounter.java @ 29994
History | View | Annotate | Download (840 Bytes)
1 |
package org.gvsig.graph.core; |
---|---|
2 |
|
3 |
/**
|
4 |
* @author fjp
|
5 |
* Used inside nodes to avoid initialization of the whole network
|
6 |
*
|
7 |
*/
|
8 |
public class GlobalCounter { |
9 |
static int numSolucGlobal = 0; |
10 |
|
11 |
public static int getGlobalSolutionNumber() { |
12 |
return numSolucGlobal;
|
13 |
} |
14 |
|
15 |
public static void setGlobalSolutionNumber(int numSolucGlobal) { |
16 |
GlobalCounter.numSolucGlobal = numSolucGlobal; |
17 |
} |
18 |
|
19 |
/**
|
20 |
* @return true if you need to initalize all nodes (every 65000 solutions only)
|
21 |
* if true, do:
|
22 |
* for (nodeNum = 0; nodeNum < graph.numVertices(); nodeNum++) {
|
23 |
node = graph.getNodeByID(nodeNum);
|
24 |
node.initialize();
|
25 |
}
|
26 |
|
27 |
*/
|
28 |
public static boolean increment() { |
29 |
if (numSolucGlobal > 65000) { |
30 |
numSolucGlobal = -1;
|
31 |
return true; |
32 |
} // for nodeNum */
|
33 |
numSolucGlobal++; |
34 |
return false; |
35 |
|
36 |
} |
37 |
|
38 |
} |