AvalonStudio.TextEditor.Document.TextAnchorTree.CheckNodeProperties C# (CSharp) Method

CheckNodeProperties() private method

private CheckNodeProperties ( TextAnchorNode node, TextAnchorNode parentNode, bool parentColor, int blackCount, int &expectedBlackCount ) : void
node TextAnchorNode
parentNode TextAnchorNode
parentColor bool
blackCount int
expectedBlackCount int
return void
		private void CheckNodeProperties(TextAnchorNode node, TextAnchorNode parentNode, bool parentColor, int blackCount,
			ref int expectedBlackCount)
		{
			if (node == null) return;

			Debug.Assert(node.parent == parentNode);

			if (parentColor == RED)
			{
				Debug.Assert(node.color == BLACK);
			}
			if (node.color == BLACK)
			{
				blackCount++;
			}
			if (node.left == null && node.right == null)
			{
				// node is a leaf node:
				if (expectedBlackCount == -1)
					expectedBlackCount = blackCount;
				else
					Debug.Assert(expectedBlackCount == blackCount);
			}
			CheckNodeProperties(node.left, node, node.color, blackCount, ref expectedBlackCount);
			CheckNodeProperties(node.right, node, node.color, blackCount, ref expectedBlackCount);
		}
#endif