-
Notifications
You must be signed in to change notification settings - Fork 0
/
secodaryColumns.c
52 lines (37 loc) · 944 Bytes
/
secodaryColumns.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include "secondaryColumns.h"
/* run after initDance */
void set_secondary_columns(Dance *d, int index)
{
d->sec_hcol_index = index;
}
/*
convert hcols
root <> ... <> temp2 <> hcol <> ... <> temp1 <> root
to
root <> ... <> temp2 <> root
hcol <> ... <> temp1 <> hcol
run this before initHeur to prevent heurs on secondary columns
*/
void stitch_secondary(Dance *d)
{
Doubly *hcol, *temp1, *temp2;
for(hcol = d->root->right; hcol->dcol != d->sec_hcol_index; hcol = hcol->right);
d->hcol_sec = hcol;
temp1 = d->root->left;
temp2 = hcol->left;
d->root->left = temp2;
temp2->right = d->root;
hcol->left = temp1;
temp1->right = hcol;
}
void unstitch_secondary(Dance *d)
{
Doubly *hcol, *temp1, *temp2;
hcol = d->hcol_sec;
temp1 = hcol->left;
temp2 = d->root->left;
d->root->left = temp1;
temp1->right = d->root;
hcol->left = temp2;
temp2->right = hcol;
}