@@ -270,152 +270,4 @@ internal Clock Current
270
270
271
271
#endregion // Data
272
272
}
273
-
274
- /// <summary>
275
- /// An object that enumerates the timelines of a tree of Timeline
276
- /// objects.
277
- /// </summary>
278
- [ FriendAccessAllowed ] // Built into Core, also used by Framework.
279
- internal struct TimelineTreeEnumerator
280
- {
281
- #region Constructor
282
- /// <summary>
283
- /// Creates an enumerator that iterates over a subtree of timelines
284
- /// in prefix order.
285
- /// </summary>
286
- /// <param name="root">
287
- /// The timeline that is the root of the subtree to enumerate.
288
- /// </param>
289
- /// <param name="processRoot">
290
- /// True to include the root in the enumeration, false otherwise.
291
- /// </param>
292
- internal TimelineTreeEnumerator ( Timeline root , bool processRoot )
293
- {
294
- _rootTimeline = root ;
295
- _flags = processRoot ? ( SubtreeFlag . Reset | SubtreeFlag . ProcessRoot ) : SubtreeFlag . Reset ;
296
-
297
- // Start with stacks of capacity 10. That's relatively small, yet
298
- // it covers very large trees without reallocation of stack data.
299
- // Note that given the way we use the stacks we need one less entry
300
- // for indices than for timelines, as we don't care what the index
301
- // of the root timeline is.
302
- _indexStack = new Stack ( 9 ) ;
303
- _timelineStack = new Stack < Timeline > ( 10 ) ;
304
- }
305
- #endregion // Constructor
306
-
307
- #region Methods
308
-
309
- /// <summary>
310
- /// Causes the enumerator to not enumerate the timelines in the subtree rooted
311
- /// at the current timeline.
312
- /// </summary>
313
- internal void SkipSubtree ( )
314
- {
315
- _flags |= SubtreeFlag . SkipSubtree ;
316
- }
317
-
318
- /// <summary>
319
- /// Advances the enumerator to the next element of the collection.
320
- /// </summary>
321
- /// <returns>
322
- /// true if the enumerator was successfully advanced to the next element,
323
- /// false if the enumerator has passed the end of the collection.
324
- /// </returns>
325
- public bool MoveNext ( )
326
- {
327
- TimelineCollection children ;
328
-
329
- // Get the iteration started in the right place, if we are just starting
330
- if ( ( _flags & SubtreeFlag . Reset ) != 0 )
331
- {
332
- // The reset flag takes effect only once
333
- _flags &= ~ SubtreeFlag . Reset ;
334
-
335
- // We are just getting started. The first timeline is the root
336
- _timelineStack . Push ( _rootTimeline ) ;
337
-
338
- // If we are not supposed to return the root, simply skip it
339
- if ( ( _flags & SubtreeFlag . ProcessRoot ) == 0 )
340
- {
341
- MoveNext ( ) ;
342
- }
343
- }
344
- else if ( _timelineStack . Count > 0 )
345
- {
346
- // Only TimelineGroup can have children
347
- TimelineGroup timelineGroup = _timelineStack . Peek ( ) as TimelineGroup ;
348
-
349
- // The next timeline is possibly the first child of the current timeline
350
- // If we have children move to the first one, unless we were
351
- // asked to skip the subtree
352
- if ( ( ( _flags & SubtreeFlag . SkipSubtree ) == 0 )
353
- && timelineGroup != null
354
- && ( children = timelineGroup . Children ) != null
355
- && children . Count > 0
356
- )
357
- {
358
- _timelineStack . Push ( children [ 0 ] ) ;
359
- _indexStack . Push ( ( int ) 0 ) ;
360
- }
361
- else
362
- {
363
- // The skip subtree flag takes effect only once
364
- _flags &= ~ SubtreeFlag . SkipSubtree ;
365
-
366
- // Move to the first ancestor that has unvisited children,
367
- // then move to the first unvisited child. If we get to
368
- // the root it means we are done.
369
- _timelineStack . Pop ( ) ;
370
- while ( _timelineStack . Count > 0 )
371
- {
372
- timelineGroup = _timelineStack . Peek ( ) as TimelineGroup ;
373
-
374
- // This has to be non-null since we already went down the tree
375
- children = timelineGroup . Children ;
376
-
377
- int index = ( int ) _indexStack . Pop ( ) + 1 ;
378
-
379
- if ( index < children . Count )
380
- {
381
- // Move to the next child, and we are done
382
- _timelineStack . Push ( children [ index ] ) ;
383
- _indexStack . Push ( index ) ;
384
- break ;
385
- }
386
-
387
- _timelineStack . Pop ( ) ;
388
- }
389
- }
390
- }
391
-
392
- return _timelineStack . Count > 0 ;
393
- }
394
-
395
- #endregion // Methods
396
-
397
- #region Properties
398
-
399
- /// <summary>
400
- /// Gets the current element in the collection.
401
- /// </summary>
402
- internal Timeline Current
403
- {
404
- get
405
- {
406
- return _timelineStack . Peek ( ) ;
407
- }
408
- }
409
-
410
- #endregion // Properties
411
-
412
- #region Data
413
-
414
- private Timeline _rootTimeline ;
415
- private SubtreeFlag _flags ;
416
- private Stack _indexStack ;
417
- private Stack < Timeline > _timelineStack ;
418
-
419
- #endregion // Data
420
- }
421
273
}
0 commit comments