Mercurial > emacs
comparison src/intervals.c @ 1412:6097878fbd46
* intervals.c (traverse_intervals): New parameter `depth'.
Increment this when passing recursively.
author | Joseph Arceneaux <jla@gnu.org> |
---|---|
date | Wed, 14 Oct 1992 23:12:09 +0000 |
parents | f09c5c6563b8 |
children | 8bc716df45e3 |
comparison
equal
deleted
inserted
replaced
1411:0b98dbec0738 | 1412:6097878fbd46 |
---|---|
171 | 171 |
172 static int icount; | 172 static int icount; |
173 static int idepth; | 173 static int idepth; |
174 static int zero_length; | 174 static int zero_length; |
175 | 175 |
176 static int depth; | |
177 | |
178 /* Traverse an interval tree TREE, performing FUNCTION on each node. | 176 /* Traverse an interval tree TREE, performing FUNCTION on each node. |
179 | 177 |
180 Perhaps we should pass the depth as an argument. */ | 178 Perhaps we should pass the depth as an argument. */ |
181 | 179 |
182 void | 180 void |
183 traverse_intervals (tree, position, function) | 181 traverse_intervals (tree, position, depth, function) |
184 INTERVAL tree; | 182 INTERVAL tree; |
185 int position; | 183 int position, depth; |
186 void (* function) (); | 184 void (* function) (); |
187 { | 185 { |
188 if (NULL_INTERVAL_P (tree)) | 186 if (NULL_INTERVAL_P (tree)) |
189 return; | 187 return; |
190 | 188 |
191 depth++; | 189 traverse_intervals (tree->left, position, depth + 1, function); |
192 traverse_intervals (tree->left, position, function); | |
193 position += LEFT_TOTAL_LENGTH (tree); | 190 position += LEFT_TOTAL_LENGTH (tree); |
194 tree->position = position; | 191 tree->position = position; |
195 (*function) (tree); | 192 (*function) (tree); |
196 position += LENGTH (tree); | 193 position += LENGTH (tree); |
197 traverse_intervals (tree->right, position, function); | 194 traverse_intervals (tree->right, position, depth + 1, function); |
198 depth--; | |
199 } | 195 } |
200 | 196 |
201 #if 0 | 197 #if 0 |
202 /* These functions are temporary, for debugging purposes only. */ | 198 /* These functions are temporary, for debugging purposes only. */ |
203 | 199 |
219 register INTERVAL i, tree; | 215 register INTERVAL i, tree; |
220 { | 216 { |
221 icount = 0; | 217 icount = 0; |
222 search_interval = i; | 218 search_interval = i; |
223 found_interval = NULL_INTERVAL; | 219 found_interval = NULL_INTERVAL; |
224 traverse_intervals (tree, 1, &check_for_interval); | 220 traverse_intervals (tree, 1, 0, &check_for_interval); |
225 return found_interval; | 221 return found_interval; |
226 } | 222 } |
227 | 223 |
228 static void | 224 static void |
229 inc_interval_count (i) | 225 inc_interval_count (i) |
241 register INTERVAL i; | 237 register INTERVAL i; |
242 { | 238 { |
243 icount = 0; | 239 icount = 0; |
244 idepth = 0; | 240 idepth = 0; |
245 zero_length = 0; | 241 zero_length = 0; |
246 traverse_intervals (i, 1, &inc_interval_count); | 242 traverse_intervals (i, 1, 0, &inc_interval_count); |
247 | 243 |
248 return icount; | 244 return icount; |
249 } | 245 } |
250 | 246 |
251 static INTERVAL | 247 static INTERVAL |