diff options
author | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
---|---|---|
committer | Adam <you@example.com> | 2020-05-17 05:51:50 +0200 |
commit | e611b132f9b8abe35b362e5870b74bce94a1e58e (patch) | |
tree | a5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/rpc/ndrdbg/pdict.hxx | |
download | NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2 NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip |
Diffstat (limited to 'private/rpc/ndrdbg/pdict.hxx')
-rw-r--r-- | private/rpc/ndrdbg/pdict.hxx | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/private/rpc/ndrdbg/pdict.hxx b/private/rpc/ndrdbg/pdict.hxx new file mode 100644 index 000000000..a566701fb --- /dev/null +++ b/private/rpc/ndrdbg/pdict.hxx @@ -0,0 +1,116 @@ +/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + Copyright (c) 1989 Microsoft Corporation + + Module Name: + + pdict.cxx + + Abstract: + + This file contains the definition for splay tree self + adjusting binary trees. + + History: + + 1990 Dov Harel Created + + ----------------------------------------------------------------------------*/ + +#ifndef __DICT_HXX__ +#define __DICT_HXX__ + +#ifndef Nil +#define Nil 0 +#endif + +#ifndef DICT_MYSPLAY +#define VIRT_SPLAY +#else +#define VIRT_SPLAY virtual +#endif + +typedef void * pUserType; + +class TreeNode { + +public: + TreeNode *left; /* left child pointer */ + TreeNode *right; /* right child pointer */ + pUserType item; /* pointer to some structure */ + + TreeNode(pUserType itemI) + { + left = right = Nil; + item = itemI; + } +}; + +typedef int (* CompareFN)(pUserType, pUserType); + +typedef enum { + SUCCESS, + ITEM_ALREADY_PRESENT, + ITEM_NOT_FOUND, + FIRST_ITEM, + LAST_ITEM, + EMPTY_DICTIONARY, + NULL_ITEM +} Dict_Status; + +class Dictionary { + TreeNode * root; // pointer to the root of a SAT + long fCompare; // value of last compare + pUserType itemCur; // the current item + long size; // number of records in dictionary/ + +public: + + Dictionary() + { + root = Nil; + size = 0; + } + + long SplayUserType(pUserType); + + // default comparison is (signed) comparison of pointers to entries + virtual + int Compare (pUserType p1, pUserType p2) + { + long l1 = (long)p1; + long l2 = (long)p2; + + return l1 - l2; + } + + pUserType Dict_Curr_Item () + { // return the top of the tree + return ((root)? root->item: Nil); + } + + pUserType Dict_Item () + { // return item from Find/Next/Prev methods + return (itemCur); + } + + long Dict_Empty () + { // Is the tree empty + return (root == Nil); + } + + Dict_Status Dict_Find(pUserType); // Item searched for + + Dict_Status Dict_Init() // First item of a Type + { + return Dict_Next( (pUserType) 0 ); + } + + Dict_Status Dict_Next(pUserType = Nil); // Next item of a Type + Dict_Status Dict_Prev(pUserType = Nil); // Previous item of a Type + + Dict_Status Dict_Insert(pUserType); // Add a new item to the tree + Dict_Status Dict_Delete(pUserType *); // Delete an item form the tree + // returns the item just deleted +}; + +#endif // __DICT_HXX__ |