[GRASS-SVN] r68970 - grass/trunk/raster/r.clump

svn_grass at osgeo.org svn_grass at osgeo.org
Thu Jul 14 13:54:01 PDT 2016


Author: mmetz
Date: 2016-07-14 13:54:01 -0700 (Thu, 14 Jul 2016)
New Revision: 68970

Added:
   grass/trunk/raster/r.clump/rclist.c
   grass/trunk/raster/r.clump/rclist.h
Log:
r.clump: +minimum size of clumps add rclist

Added: grass/trunk/raster/r.clump/rclist.c
===================================================================
--- grass/trunk/raster/r.clump/rclist.c	                        (rev 0)
+++ grass/trunk/raster/r.clump/rclist.c	2016-07-14 20:54:01 UTC (rev 68970)
@@ -0,0 +1,68 @@
+#include <grass/gis.h>
+#include <grass/glocale.h>
+#include "rclist.h"
+
+void rclist_init(struct rclist *list)
+{
+    list->head = list->tail = NULL;
+    
+    return;
+}
+
+void rclist_add(struct rclist *list, int row, int col)
+{
+    struct rc *new = G_malloc(sizeof(struct rc));
+
+    if (!new)
+	G_fatal_error(_("rclist out of memory"));
+
+    new->next = NULL;
+    new->row = row;
+    new->col = col;
+    
+    if (list->head) {
+	list->head->next = new;
+	list->head = new;
+    }
+    else {
+	list->head = list->tail = new;
+    }
+    
+    return;
+}
+
+/* return 1 if an element was dropped
+ * return 0 if list is empty
+ */
+int rclist_drop(struct rclist *list, struct rc *rc)
+{
+    if (list->tail) {
+	struct rc *next = list->tail->next;
+
+	rc->row = list->tail->row;
+	rc->col = list->tail->col;
+	G_free(list->tail);
+	list->tail = next;
+	if (!list->tail)
+	    list->head = NULL;
+
+	return 1;
+    }
+
+    return 0;
+}
+
+void rclist_destroy(struct rclist *list)
+{
+    struct rc *next = list->tail;
+    
+    while (next) {
+	next = next->next;
+	G_free(list->tail);
+	list->tail = next;
+    }
+    list->head = NULL;
+    
+    return;
+}
+


Property changes on: grass/trunk/raster/r.clump/rclist.c
___________________________________________________________________
Added: svn:mime-type
   + text/x-csrc
Added: svn:eol-style
   + native

Added: grass/trunk/raster/r.clump/rclist.h
===================================================================
--- grass/trunk/raster/r.clump/rclist.h	                        (rev 0)
+++ grass/trunk/raster/r.clump/rclist.h	2016-07-14 20:54:01 UTC (rev 68970)
@@ -0,0 +1,20 @@
+/* row/col list */
+
+struct rc
+{
+    struct rc *next;
+    int row;
+    int col;
+};
+
+struct rclist
+{
+    struct rc *tail, *head;
+};
+
+/* rclist.c */
+void rclist_init(struct rclist *);
+void rclist_add(struct rclist *, int, int);
+int rclist_drop(struct rclist *, struct rc *);
+void rclist_destroy(struct rclist *);
+


Property changes on: grass/trunk/raster/r.clump/rclist.h
___________________________________________________________________
Added: svn:mime-type
   + text/x-chdr
Added: svn:eol-style
   + native



More information about the grass-commit mailing list