Commit c1d46149 authored by Alexandre Julliard's avatar Alexandre Julliard

rbtree.h: Add a wine_rb_prev iteration helper function.

parent 917d98a4
......@@ -101,6 +101,13 @@ static inline struct wine_rb_entry *wine_rb_head(struct wine_rb_entry *iter)
return iter;
}
static inline struct wine_rb_entry *wine_rb_tail(struct wine_rb_entry *iter)
{
if (!iter) return NULL;
while (iter->right) iter = iter->right;
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);
......@@ -108,6 +115,13 @@ static inline struct wine_rb_entry *wine_rb_next(struct wine_rb_entry *iter)
return iter->parent;
}
static inline struct wine_rb_entry *wine_rb_prev(struct wine_rb_entry *iter)
{
if (iter->left) return wine_rb_tail(iter->left);
while (iter->parent && iter->parent->left == 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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment