mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 15:02:59 +00:00
- Implement RtlSplay skeleton cases.
svn path=/trunk/; revision=19072
This commit is contained in:
parent
bc90bf5915
commit
3d244e2b37
2 changed files with 57 additions and 2 deletions
|
@ -24,6 +24,9 @@
|
||||||
#define RtlIsLeftChild(Links) \
|
#define RtlIsLeftChild(Links) \
|
||||||
(RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
|
(RtlLeftChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
|
||||||
|
|
||||||
|
#define RtlIsRightChild(Links) \
|
||||||
|
(RtlRightChild(RtlParent(Links)) == (PRTL_SPLAY_LINKS)(Links))
|
||||||
|
|
||||||
#define RtlRightChild(Links) \
|
#define RtlRightChild(Links) \
|
||||||
((PRTL_SPLAY_LINKS)(Links))->RightChild
|
((PRTL_SPLAY_LINKS)(Links))->RightChild
|
||||||
|
|
||||||
|
|
|
@ -109,8 +109,60 @@ RtlSplay(PRTL_SPLAY_LINKS Links)
|
||||||
* we keep recently accessed nodes near the root and keep the tree
|
* we keep recently accessed nodes near the root and keep the tree
|
||||||
* roughly balanced, so that we achieve the desired amortized time bounds.
|
* roughly balanced, so that we achieve the desired amortized time bounds.
|
||||||
*/
|
*/
|
||||||
UNIMPLEMENTED;
|
PRTL_SPLAY_LINKS N, P, G;
|
||||||
return 0;
|
|
||||||
|
/* N is the item we'll be playing with */
|
||||||
|
N = Links;
|
||||||
|
|
||||||
|
/* Let the algorithm run until N becomes the root entry */
|
||||||
|
while (!RtlIsRoot(N))
|
||||||
|
{
|
||||||
|
/* Now get the parent and grand-parent */
|
||||||
|
P = RtlParent(N);
|
||||||
|
G = RtlParent(P);
|
||||||
|
|
||||||
|
/* Case 1 & 3: N is left child of P */
|
||||||
|
if (RtlIsLeftChild(N))
|
||||||
|
{
|
||||||
|
/* Case 1: P is the left child of G */
|
||||||
|
if (RtlIsLeftChild(P))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Case 3: P is the right child of G */
|
||||||
|
else if (RtlIsRightChild(P))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/* "Finally" case: N doesn't have a grandparent => P is root */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Case 2 & 4: N is right child of P */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Case 2: P is the left child of G */
|
||||||
|
if (RtlIsLeftChild(P))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/* Case 4: P is the right child of G */
|
||||||
|
else if (RtlIsRightChild(P))
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/* "Finally" case: N doesn't have a grandparent => P is root */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Return the root entry */
|
||||||
|
return N;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue