Code Coverage Statistics for Source File

c:\Tools\SD3\src\Libraries\ICSharpCode.TextEditor\Project\Src\Util\RedBlackTreeIterator.cs

Sequence Point Coverage
N/A
0 of 0
Branch Coverage
N/A
0 of 0
Lines
85
Highlight: Uncovered Code Covered Code
L V Source
1
// <file>
2
//     <copyright see="prj:///doc/copyright.txt"/>
3
//     <license see="prj:///doc/license.txt"/>
4
//     <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
5
//     <version>$Revision: 2497 $</version>
6
// </file>
7
8
using System;
9
using System.Diagnostics;
10
using System.Collections.Generic;
11
12
namespace ICSharpCode.TextEditor.Util
13
{
14
	internal struct RedBlackTreeIterator<T> : IEnumerator<T>
15
	{
16
		internal RedBlackTreeNode<T> node;
17
		
18
		internal RedBlackTreeIterator(RedBlackTreeNode<T> node)
19
		{
20
			this.node = node;
21
		}
22
		
23
		public bool IsValid {
24
			get { return node != null; }
25
		}
26
		
27
		public T Current {
28
			get {
29
				if (node != null)
30
					return node.val;
31
				else
32
					throw new InvalidOperationException();
33
			}
34
		}
35
		
36
		object System.Collections.IEnumerator.Current {
37
			get {
38
				return this.Current;
39
			}
40
		}
41
		
42
		void IDisposable.Dispose()
43
		{
44
		}
45
		
46
		void System.Collections.IEnumerator.Reset()
47
		{
48
			throw new NotSupportedException();
49
		}
50
		
51
		public bool MoveNext()
52
		{
53
			if (node == null)
54
				return false;
55
			if (node.right != null) {
56
				node = node.right.LeftMost;
57
			} else {
58
				RedBlackTreeNode<T> oldNode;
59
				do {
60
					oldNode = node;
61
					node = node.parent;
62
					// we are on the way up from the right part, don't output node again
63
				} while (node != null && node.right == oldNode);
64
			}
65
			return node != null;
66
		}
67
		
68
		public bool MoveBack()
69
		{
70
			if (node == null)
71
				return false;
72
			if (node.left != null) {
73
				node = node.left.RightMost;
74
			} else {
75
				RedBlackTreeNode<T> oldNode;
76
				do {
77
					oldNode = node;
78
					node = node.parent;
79
					// we are on the way up from the left part, don't output node again
80
				} while (node != null && node.left == oldNode);
81
			}
82
			return node != null;
83
		}
84
	}
85
}