Java Reference
In-Depth Information
for (int k = 0; k < n; ++k) {
edgelist:
{
int z;
search:
{
if (k == i) {
for (z = 0; z < edges[k].length; ++z) {
if (edges[k][z] == j) break search;
}
} else if (k == j) {
for (z = 0; z < edges[k].length; ++z) {
if (edges[k][z] == i) break search;
}
}
// No edge to be deleted; share this list.
newedges[k] = edges[k];
break edgelist;
} //search
// Copy the list, omitting the edge at position z.
int m = edges[k].length - 1;
int ne[] = new int[m];
System.arraycopy(edges[k], 0, ne, 0, z);
System.arraycopy(edges[k], z+1, ne, z, m-z);
newedges[k] = ne;
} //edgelist
}
return new Graph(newedges);
}
}
Note the use of two statement labels, edgelist and search , and the use of break statements.
This allows the code that copies a list, omitting one edge, to be shared between two
separate tests, the test for an edge from node i to node j , and the test for an edge from
node j to node i .
14.16. The continue Statement
A continue statement may occur only in a while , do , or for statement; statements of these three
kinds are called iteration statements . Control passes to the loop-continuation point of an
iteration statement.
ContinueStatement:
continue Identifier opt ;
Search WWH ::




Custom Search