summaryrefslogtreecommitdiff
path: root/gtk/gtkrbtree.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2011-11-22 02:58:05 +0100
committerBenjamin Otte <otte@redhat.com>2011-11-22 03:32:56 +0100
commitc3056951dbd5ee7b3d9052ce5e9e8f5e1864f639 (patch)
treee3ab64c4d092c4cf9ef825239d1c73961d93b2db /gtk/gtkrbtree.c
parent73a834336fd8d67cde6c9739e88744f96af57ceb (diff)
downloadgtk+-c3056951dbd5ee7b3d9052ce5e9e8f5e1864f639.tar.gz
rbtree: Introduce _gtk_rbtree_first()
... and use it.
Diffstat (limited to 'gtk/gtkrbtree.c')
-rw-r--r--gtk/gtkrbtree.c40
1 files changed, 21 insertions, 19 deletions
diff --git a/gtk/gtkrbtree.c b/gtk/gtkrbtree.c
index a9ec7039b2..35d8134ddf 100644
--- a/gtk/gtkrbtree.c
+++ b/gtk/gtkrbtree.c
@@ -722,11 +722,8 @@ _gtk_rbtree_column_invalid (GtkRBTree *tree)
if (tree == NULL)
return;
- node = tree->root;
- g_assert (node);
- while (node->left != tree->nil)
- node = node->left;
+ node = _gtk_rbtree_first (tree);
do
{
@@ -747,11 +744,8 @@ _gtk_rbtree_mark_invalid (GtkRBTree *tree)
if (tree == NULL)
return;
- node = tree->root;
- g_assert (node);
- while (node->left != tree->nil)
- node = node->left;
+ node = _gtk_rbtree_first (tree);
do
{
@@ -774,11 +768,7 @@ _gtk_rbtree_set_fixed_height (GtkRBTree *tree,
if (tree == NULL)
return;
- node = tree->root;
- g_assert (node);
-
- while (node->left != tree->nil)
- node = node->left;
+ node = _gtk_rbtree_first (tree);
do
{
@@ -888,9 +878,7 @@ _gtk_rbtree_reorder (GtkRBTree *tree,
g_array_sort(array, gtk_rbtree_reorder_sort_func);
/* rewind node*/
- node = tree->root;
- while (node && node->left != tree->nil)
- node = node->left;
+ node = _gtk_rbtree_first (tree);
for (i = 0; i < length; i++)
{
@@ -905,9 +893,7 @@ _gtk_rbtree_reorder (GtkRBTree *tree,
g_array_sort (array, gtk_rbtree_reorder_invert_func);
/* rewind node*/
- node = tree->root;
- while (node && node->left != tree->nil)
- node = node->left;
+ node = _gtk_rbtree_first (tree);
/* Go through the tree and change the values to the new ones. */
for (i = 0; i < length; i++)
@@ -1260,6 +1246,22 @@ _gtk_rbtree_remove_node (GtkRBTree *tree,
}
GtkRBNode *
+_gtk_rbtree_first (GtkRBTree *tree)
+{
+ GtkRBNode *node;
+
+ node = tree->root;
+
+ if (node == tree->nil)
+ return NULL;
+
+ while (node->left != tree->nil)
+ node = node->left;
+
+ return node;
+}
+
+GtkRBNode *
_gtk_rbtree_next (GtkRBTree *tree,
GtkRBNode *node)
{