xref: /reactos/sdk/lib/rtl/rtlavl.h (revision 34593d93)
1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  * PROJECT:         ReactOS Runtime Library
3*c2c66affSColin Finck  * LICENSE:         BSD - See COPYING.ARM in the top level directory
4*c2c66affSColin Finck  * FILE:            lib/rtl/rtlavl.h
5*c2c66affSColin Finck  * PURPOSE:         RTL AVL Glue
6*c2c66affSColin Finck  * PROGRAMMERS:     ReactOS Portable Systems Group
7*c2c66affSColin Finck  */
8*c2c66affSColin Finck 
9*c2c66affSColin Finck /* INCLUDES ******************************************************************/
10*c2c66affSColin Finck 
11*c2c66affSColin Finck /*
12*c2c66affSColin Finck  * This is the glue code for the AVL package in the RTL meant for external callers.
13*c2c66affSColin Finck  * It's not very exciting, it just uses the RTL-defined fields without any magic,
14*c2c66affSColin Finck  * unlike the Mm version which has special handling for balances and parents, and
15*c2c66affSColin Finck  * does not implement custom comparison callbacks.
16*c2c66affSColin Finck  */
17*c2c66affSColin Finck #define MI_ASSERT(x)
18*c2c66affSColin Finck #define RtlLeftChildAvl(x)          (PRTL_BALANCED_LINKS)(RtlLeftChild(x))
19*c2c66affSColin Finck #define RtlRightChildAvl(x)         (PRTL_BALANCED_LINKS)(RtlRightChild(x))
20*c2c66affSColin Finck #define RtlParentAvl(x)             (PRTL_BALANCED_LINKS)(RtlParent(x))
21*c2c66affSColin Finck #define RtlRealPredecessorAvl(x)    (PRTL_BALANCED_LINKS)(RtlRealPredecessor((PRTL_SPLAY_LINKS)(x)))
22*c2c66affSColin Finck #define RtlRealSuccessorAvl(x)      (PRTL_BALANCED_LINKS)(RtlRealSuccessor((PRTL_SPLAY_LINKS)(x)))
23*c2c66affSColin Finck #define RtlInsertAsRightChildAvl    RtlInsertAsRightChild
24*c2c66affSColin Finck #define RtlInsertAsLeftChildAvl     RtlInsertAsLeftChild
25*c2c66affSColin Finck #define RtlIsLeftChildAvl           RtlIsLeftChild
26*c2c66affSColin Finck 
27*c2c66affSColin Finck FORCEINLINE
28*c2c66affSColin Finck VOID
RtlpCopyAvlNodeData(IN PRTL_BALANCED_LINKS Node1,IN PRTL_BALANCED_LINKS Node2)29*c2c66affSColin Finck RtlpCopyAvlNodeData(IN PRTL_BALANCED_LINKS Node1,
30*c2c66affSColin Finck                     IN PRTL_BALANCED_LINKS Node2)
31*c2c66affSColin Finck {
32*c2c66affSColin Finck     *Node1 = *Node2;
33*c2c66affSColin Finck }
34*c2c66affSColin Finck 
35*c2c66affSColin Finck FORCEINLINE
36*c2c66affSColin Finck RTL_GENERIC_COMPARE_RESULTS
RtlpAvlCompareRoutine(IN PRTL_AVL_TABLE Table,IN PVOID Buffer,IN PVOID UserData)37*c2c66affSColin Finck RtlpAvlCompareRoutine(IN PRTL_AVL_TABLE Table,
38*c2c66affSColin Finck                       IN PVOID Buffer,
39*c2c66affSColin Finck                       IN PVOID UserData)
40*c2c66affSColin Finck {
41*c2c66affSColin Finck     /* Do the compare */
42*c2c66affSColin Finck     return Table->CompareRoutine(Table,
43*c2c66affSColin Finck                                  Buffer,
44*c2c66affSColin Finck                                  UserData);
45*c2c66affSColin Finck }
46*c2c66affSColin Finck 
47*c2c66affSColin Finck FORCEINLINE
48*c2c66affSColin Finck VOID
RtlSetParent(IN PRTL_BALANCED_LINKS Node,IN PRTL_BALANCED_LINKS Parent)49*c2c66affSColin Finck RtlSetParent(IN PRTL_BALANCED_LINKS Node,
50*c2c66affSColin Finck              IN PRTL_BALANCED_LINKS Parent)
51*c2c66affSColin Finck {
52*c2c66affSColin Finck     Node->Parent = Parent;
53*c2c66affSColin Finck }
54*c2c66affSColin Finck 
55*c2c66affSColin Finck FORCEINLINE
56*c2c66affSColin Finck VOID
RtlSetBalance(IN PRTL_BALANCED_LINKS Node,IN CHAR Balance)57*c2c66affSColin Finck RtlSetBalance(IN PRTL_BALANCED_LINKS Node,
58*c2c66affSColin Finck               IN CHAR Balance)
59*c2c66affSColin Finck {
60*c2c66affSColin Finck     Node->Balance = Balance;
61*c2c66affSColin Finck }
62*c2c66affSColin Finck 
63*c2c66affSColin Finck FORCEINLINE
64*c2c66affSColin Finck CHAR
RtlBalance(IN PRTL_BALANCED_LINKS Node)65*c2c66affSColin Finck RtlBalance(IN PRTL_BALANCED_LINKS Node)
66*c2c66affSColin Finck {
67*c2c66affSColin Finck     return Node->Balance;
68*c2c66affSColin Finck }
69*c2c66affSColin Finck 
70*c2c66affSColin Finck /* EOF */
71