Selaa lähdekoodia

polished Red Black Tree used

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@36517 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 16 vuotta sitten
vanhempi
commit
e6438303a0
1 muutettua tiedostoa jossa 7 lisäystä ja 7 poistoa
  1. 7 7
      lib/vector/Vlib/break_polygons.c

+ 7 - 7
lib/vector/Vlib/break_polygons.c

@@ -68,16 +68,16 @@ int compare_xpnts(const void *Xpnta, const void *Xpntb)
     b = (XPNT *)Xpntb;
 
     if (a->x > b->x)
-	return 0;
-    else if (a->x < b->x)
 	return 1;
+    else if (a->x < b->x)
+	return -1;
     else {
 	if (a->y > b->y)
-	    return 0;
-	else if (a->y < b->y)
 	    return 1;
+	else if (a->y < b->y)
+	    return -1;
 	else
-	    return 2;
+	    return 0;
     }
 
     G_warning("Break polygons: Bug in binary tree!");
@@ -130,7 +130,7 @@ Vect_break_polygons(struct Map_info *Map, int type, struct Map_info *Err)
 
     apoints = 0;
     nmarks = 0;
-    npoints = 1;		/* index starts from 1 ! */
+    npoints = 0;
     nallpoints = 0;
 
     G_verbose_message(_("Break polygons Pass 1: select break points"));
@@ -231,9 +231,9 @@ Vect_break_polygons(struct Map_info *Map, int type, struct Map_info *Err)
 		    XPnt_search.a2 = a2;
 		    XPnt_search.cross = 0;
 		}
+
 		/* Add to tree */
 		rbtree_insert(RBTree, &XPnt_search);
-
 		npoints++;
 	    }
 	}