[Roxygen-commits] r67 - pkg/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Jul 20 20:03:02 CEST 2008


Author: pcd
Date: 2008-07-20 20:03:02 +0200 (Sun, 20 Jul 2008)
New Revision: 67

Modified:
   pkg/R/collate.R
Log:
simplified topological


Modified: pkg/R/collate.R
===================================================================
--- pkg/R/collate.R	2008-07-20 18:02:52 UTC (rev 66)
+++ pkg/R/collate.R	2008-07-20 18:03:02 UTC (rev 67)
@@ -6,15 +6,9 @@
   make.vertex <- function(file) {
     vertex <- new.env(parent=emptyenv())
     vertex$file <- trim(file)
-    vertex$discovered <- -1
-    vertex$finished <- -1
-    vertex$predecessor <- NULL
+    vertex$discovered <- F
     vertex$ancestors <- NULL
-    vertex$is.discovered <-
-      function() vertex$discovered >= 0
-    vertex$is.finished <-
-      function() vertex$discovered >= 0
-    structure(vertex, class='vertex')
+    vertex
   }
 
   maybe.append.vertex <- function(file)
@@ -50,24 +44,18 @@
   }
 
   topological.sort <- function(vertices) {
-    time <- 0
     sorted <- NULL
     visit <- function(predecessor) {
-      assign.parent('time', time + 1, environment())
-      predecessor$discovered <- time
+      predecessor$discovered <- T
       for (ancestor in predecessor$ancestors)
-        if (!ancestor$is.discovered()) {
-          ancestor$predecessor <- predecessor
+        if (!ancestor$discovered)
           visit(ancestor)
-        }
-      assign.parent('time', time + 1, environment())
-      predecessor$finished <- time
       assign.parent('sorted',
                     append(sorted, predecessor),
                     environment())
     }
     for (vertex in vertices)
-      if (!vertex$is.discovered())
+      if (!vertex$discovered)
         visit(vertex)
   }
 



More information about the Roxygen-commits mailing list