bsort(field A, int l, int r) {
root:= null;
for i:= r downto l do {
top:= insert(A, root, new node_element(i));
if (top <> null) {
root:= new node_head(1, root, top);
}
}
for i:= l to r do {
B[0][i] = i;
B[1][i] = i;
}
resolve(A, B, l, root);
}
node_element insert(field A, node_head head, node_element e) {
...
}
int resolve(field A, int[][] B, int index, node_head head) {
if (head <> null) then {
current:= head;
while (current <> null) do {
index:= resolve(A, B, index, current.child);
if (current.next <> null) then {
s:= B[0][current.next.index];
t:= B[1][index];
exchange(A[s], A[index]);
B[0][t]:= s;
B[1][s]:= t;
index++;
}
current:= current.next;
}
}
return index;
}
node find_ge(field A, node_head head, node_element e) {
...
}
node find_n(node_head head, int i) {
...
}
node_element split(node_head head) {
...
}
private abstract class node {
...
}
protected class node_element extends node {
...
}
protected class node_head extends node {
...
}
|