OSDN Git Service

gcc/fortran/
[pf3gnuchains/gcc-fork.git] / gcc / fortran / bbt.c
index 3f01e70..fa60e4f 100644 (file)
@@ -1,12 +1,13 @@
 /* Balanced binary trees using treaps.
-   Copyright (C) 2000, 2002, 2003 Free Software Foundation, Inc.
+   Copyright (C) 2000, 2002, 2003, 2007, 2008
+   Free Software Foundation, Inc.
    Contributed by Andy Vaught
 
 This file is part of GCC.
 
 GCC is free software; you can redistribute it and/or modify it under
 the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
+Software Foundation; either version 3, or (at your option) any later
 version.
 
 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -15,9 +16,8 @@ FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.
 
 You should have received a copy of the GNU General Public License
-along with GCC; see the file COPYING.  If not, write to the Free
-Software Foundation, 59 Temple Place - Suite 330, Boston, MA
-02111-1307, USA.  */
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
 
 /* The idea is to balance the tree using pseudorandom numbers.  The
    main constraint on this implementation is that we have several
@@ -62,7 +62,7 @@ pseudo_random (void)
 /* Rotate the treap left.  */
 
 static gfc_bbt *
-rotate_left (gfc_bbt * t)
+rotate_left (gfc_bbt *t)
 {
   gfc_bbt *temp;
 
@@ -77,7 +77,7 @@ rotate_left (gfc_bbt * t)
 /* Rotate the treap right.  */
 
 static gfc_bbt *
-rotate_right (gfc_bbt * t)
+rotate_right (gfc_bbt *t)
 {
   gfc_bbt *temp;
 
@@ -93,29 +93,27 @@ rotate_right (gfc_bbt * t)
    aborts if we find a duplicate key.  */
 
 static gfc_bbt *
-insert (gfc_bbt * new, gfc_bbt * t, compare_fn compare)
+insert (gfc_bbt *new_bbt, gfc_bbt *t, compare_fn compare)
 {
   int c;
 
   if (t == NULL)
-    return new;
+    return new_bbt;
 
-  c = (*compare) (new, t);
+  c = (*compare) (new_bbt, t);
 
   if (c < 0)
     {
-      t->left = insert (new, t->left, compare);
+      t->left = insert (new_bbt, t->left, compare);
       if (t->priority < t->left->priority)
        t = rotate_right (t);
     }
-
   else if (c > 0)
     {
-      t->right = insert (new, t->right, compare);
+      t->right = insert (new_bbt, t->right, compare);
       if (t->priority < t->right->priority)
        t = rotate_left (t);
     }
-
   else /* if (c == 0)  */
     gfc_internal_error("insert_bbt(): Duplicate key found!");
 
@@ -128,19 +126,18 @@ insert (gfc_bbt * new, gfc_bbt * t, compare_fn compare)
    already exists.  */
 
 void
-gfc_insert_bbt (void *root, void *new, compare_fn compare)
+gfc_insert_bbt (void *root, void *new_node, compare_fn compare)
 {
   gfc_bbt **r, *n;
 
   r = (gfc_bbt **) root;
-  n = (gfc_bbt *) new;
-
+  n = (gfc_bbt *) new_node;
   n->priority = pseudo_random ();
   *r = insert (n, *r, compare);
 }
 
 static gfc_bbt *
-delete_root (gfc_bbt * t)
+delete_root (gfc_bbt *t)
 {
   gfc_bbt *temp;
 
@@ -170,7 +167,7 @@ delete_root (gfc_bbt * t)
    Returns the new root node of the tree.  */
 
 static gfc_bbt *
-delete_treap (gfc_bbt * old, gfc_bbt * t, compare_fn compare)
+delete_treap (gfc_bbt *old, gfc_bbt *t, compare_fn compare)
 {
   int c;
 
@@ -196,6 +193,5 @@ gfc_delete_bbt (void *root, void *old, compare_fn compare)
   gfc_bbt **t;
 
   t = (gfc_bbt **) root;
-
   *t = delete_treap ((gfc_bbt *) old, *t, compare);
 }