Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
c16fb053
Commit
c16fb053
authored
Sep 20, 2016
by
Jacek Caban
Committed by
Alexandre Julliard
Sep 21, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rbtree.h: Added ordered iteration functions and macros.
Signed-off-by:
Jacek Caban
<
jacek@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
e6e8ed47
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletion
+27
-1
rbtree.h
include/wine/rbtree.h
+27
-1
No files found.
include/wine/rbtree.h
View file @
c16fb053
...
...
@@ -94,6 +94,20 @@ static inline void wine_rb_flip_color(struct wine_rb_entry *entry)
entry
->
right
->
flags
^=
WINE_RB_FLAG_RED
;
}
static
inline
struct
wine_rb_entry
*
wine_rb_head
(
struct
wine_rb_entry
*
iter
)
{
if
(
!
iter
)
return
NULL
;
while
(
iter
->
left
)
iter
=
iter
->
left
;
return
iter
;
}
static
inline
struct
wine_rb_entry
*
wine_rb_next
(
struct
wine_rb_entry
*
iter
)
{
if
(
iter
->
right
)
return
wine_rb_head
(
iter
->
right
);
while
(
iter
->
parent
&&
iter
->
parent
->
right
==
iter
)
iter
=
iter
->
parent
;
return
iter
->
parent
;
}
static
inline
struct
wine_rb_entry
*
wine_rb_postorder_head
(
struct
wine_rb_entry
*
iter
)
{
if
(
!
iter
)
return
NULL
;
...
...
@@ -112,6 +126,17 @@ static inline struct wine_rb_entry *wine_rb_postorder_next(struct wine_rb_entry
return
wine_rb_postorder_head
(
iter
->
parent
->
right
);
}
/* iterate through the tree */
#define WINE_RB_FOR_EACH(cursor, tree) \
for ((cursor) = wine_rb_head((tree)->root); (cursor); (cursor) = wine_rb_next(cursor))
/* iterate through the tree using a tree entry */
#define WINE_RB_FOR_EACH_ENTRY(elem, tree, type, field) \
for ((elem) = WINE_RB_ENTRY_VALUE(wine_rb_head((tree)->root), type, field); \
&(elem)->field; \
(elem) = WINE_RB_ENTRY_VALUE(wine_rb_next(&elem->field), type, field))
static
inline
void
wine_rb_postorder
(
struct
wine_rb_tree
*
tree
,
wine_rb_traverse_func_t
*
callback
,
void
*
context
)
{
struct
wine_rb_entry
*
iter
,
*
next
;
...
...
@@ -131,7 +156,8 @@ static inline void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_
static
inline
void
wine_rb_for_each_entry
(
struct
wine_rb_tree
*
tree
,
wine_rb_traverse_func_t
*
callback
,
void
*
context
)
{
wine_rb_postorder
(
tree
,
callback
,
context
);
struct
wine_rb_entry
*
iter
;
WINE_RB_FOR_EACH
(
iter
,
tree
)
callback
(
iter
,
context
);
}
static
inline
void
wine_rb_clear
(
struct
wine_rb_tree
*
tree
,
wine_rb_traverse_func_t
*
callback
,
void
*
context
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment