2 ExtendPathWindows(PathList raw_list)
4 // to keep track of everything, this function acts like a finite state
5 // automata: 3 bitfields: reset, extending, scanning - ie 8 states
6 int reset = 0, extending = 0, scanning = 0;
8 int species_num = raw_list.SpeciesNum();
9 int win_num = raw_list.WinNum();
11 int *cur_path, *next_path;
13 cur_path = new int[species_num];
14 next_path = new int[species_num];
16 raw_list.ResetIndex();
18 while (no more windows avaible)
20 //cur_indices[0] + ref_ext == next_indices[0] + 1:
22 // state 000 - start/nominal search
24 if !reset && !extending && !scanning
26 if cur_path[0] == next_path[0]
28 scanning = 1; // go to state 001
29 raw_list.IncreIndex();
31 else if cur_path[0] + 1 == next_path[0]
33 extending = 1; // go to state 010
36 raw_list.IncreIndex();
39 reset = 1; // go to state 100
42 // state 001 - scanning for ext window thru possible interleaving
44 else if !reset && !extending && scanning
46 if cur_path[0] == next_path[0]
47 raw_list.IncreIndex();
48 else if cur_path[0] + 1 == next_path[0]
50 extending = 1; // go to state 011
53 raw_list.IncreIndex();
56 reset = 1; // go to state 101
59 // state 010 - extending window with no interleaving
61 else if !reset && extending && !scanning
63 if (cur_path[0] + win_ext) == next_path[0]
65 extending = 1; // go to state 011
66 raw_list.IncreIndex();
68 else if (cur_path[0] + win_ext + 1) == next_path[0]
72 raw_list.IncreIndex();
75 reset = 1; // go to state 110
78 // state 011 - extending window with interleaving
80 else if !reset && extending && scanning
82 if (cur_path[0] + win_ext) == next_path[0]
83 raw_list.IncreIndex();
84 else if (cur_path[0] + win_ext + 1) == next_path[0]
88 raw_list.IncreIndex();
91 reset = 1; // go to state 111
95 // reset condition states, return to 000 after taking appropiate action
97 // state 100 - no extended window, no scanning happened
98 // save basic window to extended window list
99 if reset && !extending && !scanning
101 // return to start/nominal search state
105 // state 101 - no extended window, scanned for interleaving
106 // save basic window to extended window list, return to first clean
107 else if reset && !extending && scanning
109 // return to start/nominal search state
114 // state 110 - extended window, no interleaving
115 // calc extended window, save to extended window list
116 else if reset && extending && !scanning
118 // return to start/nominal search state
123 // state 111 - extended window, interleaved
124 // calc extended window, save to ext win list, return to first clean
125 else if reset && extending && scanning
127 // return to start/nominal search state