]> git.donarmstrong.com Git - ape.git/blobdiff - R/unique.multiPhylo.R
some big fixes for ape 2.7-1
[ape.git] / R / unique.multiPhylo.R
index a39ffdffcc9bcf5dcae47e3a00a06064b04a91ae..2887c0d1f205fe8b862b249339ca05ea4d8b79d8 100644 (file)
@@ -1,4 +1,4 @@
-## unique.multiPhylo.R (2008-02-06)
+## unique.multiPhylo.R (2008-06-09)
 
 ##   Revomes Duplicate Trees from a List
 
@@ -12,18 +12,18 @@ unique.multiPhylo <- function(x, incomparables = FALSE,
                               use.tip.label = TRUE, ...)
 {
     n <- length(x)
-    keep <- !logical(n)
+    keep <- 1L
     for (i in 2:n) {
-        j <- 1
-        while (j < i) {
-            if (all.equal(x[[j]], x[[i]],
+        already.seen <- FALSE
+        for (s in x[keep]) {
+            if (all.equal(s, x[[i]],
                           use.edge.length = use.edge.length,
                           use.tip.label = use.tip.label)) {
-                keep[i] <- FALSE
+                already.seen <- TRUE
                 break
             }
-            j <- j + 1
         }
+        if (!already.seen) keep <- c(keep, i)
     }
     x[keep]
 }