From db318aa92ea8ebf3cc9aed89ee2417bd9e715286 Mon Sep 17 00:00:00 2001 From: wj32 Date: Sat, 5 Jun 2010 02:46:24 +0000 Subject: [PATCH] added Count to trees git-svn-id: svn://svn.code.sf.net/p/processhacker/code@3182 21ef857c-d57f-4fe0-8362-d861dc6d29cd --- 2.x/trunk/phlib/bintree.c | 11 +++++++++++ 2.x/trunk/phlib/include/phbase.h | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/2.x/trunk/phlib/bintree.c b/2.x/trunk/phlib/bintree.c index 78c30db35..fccd1643c 100644 --- a/2.x/trunk/phlib/bintree.c +++ b/2.x/trunk/phlib/bintree.c @@ -30,6 +30,7 @@ VOID PhInitializeBinaryTree( Tree->Root.Parent = NULL; Tree->Root.Left = NULL; Tree->Root.Right = NULL; + Tree->Count = 0; Tree->CompareFunction = CompareFunction; } @@ -113,6 +114,8 @@ PPH_BINARY_LINKS PhBinaryTreeAdd( Subject->Left = NULL; Subject->Right = NULL; + Tree->Count++; + return NULL; } @@ -170,6 +173,8 @@ VOID PhBinaryTreeRemove( if (child->Right) child->Right->Parent = child; } + + Tree->Count--; } PPH_BINARY_LINKS PhBinaryTreeSearch( @@ -197,6 +202,8 @@ VOID PhInitializeAvlTree( Tree->Root.Left = NULL; Tree->Root.Right = NULL; Tree->Root.Balance = 0; + Tree->Count = 0; + Tree->CompareFunction = CompareFunction; } @@ -709,6 +716,8 @@ PPH_AVL_LINKS PhAvlTreeAdd( } } + Tree->Count++; + return NULL; } @@ -829,6 +838,8 @@ VOID PhAvlTreeRemove( if (newSubject->Right) newSubject->Right->Parent = newSubject; } + + Tree->Count--; } PPH_AVL_LINKS PhAvlTreeSearch( diff --git a/2.x/trunk/phlib/include/phbase.h b/2.x/trunk/phlib/include/phbase.h index 6fe34783b..5fc22a009 100644 --- a/2.x/trunk/phlib/include/phbase.h +++ b/2.x/trunk/phlib/include/phbase.h @@ -1810,6 +1810,8 @@ typedef INT (NTAPI *PPH_BINARY_TREE_COMPARE_FUNCTION)( typedef struct _PH_BINARY_TREE { PH_BINARY_LINKS Root; // Right contains real root + ULONG Count; + PPH_BINARY_TREE_COMPARE_FUNCTION CompareFunction; } PH_BINARY_TREE, *PPH_BINARY_TREE; @@ -1851,6 +1853,8 @@ typedef INT (NTAPI *PPH_AVL_TREE_COMPARE_FUNCTION)( typedef struct _PH_AVL_TREE { PH_AVL_LINKS Root; // Right contains real root + ULONG Count; + PPH_AVL_TREE_COMPARE_FUNCTION CompareFunction; } PH_AVL_TREE, *PPH_AVL_TREE;