X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=R%2Funique.multiPhylo.R;h=2887c0d1f205fe8b862b249339ca05ea4d8b79d8;hb=7af63afb401f7cc82816b0af19e21c43fab49674;hp=56f4fbbd392f283b1947bd688bdffb6bbe52b717;hpb=c827059eeafc8cbe41c812b26979543ab287803e;p=ape.git diff --git a/R/unique.multiPhylo.R b/R/unique.multiPhylo.R index 56f4fbb..2887c0d 100644 --- a/R/unique.multiPhylo.R +++ b/R/unique.multiPhylo.R @@ -1,8 +1,8 @@ -## unique.multiPhylo.R (2007-11-16) +## unique.multiPhylo.R (2008-06-09) ## Revomes Duplicate Trees from a List -## Copyright 2007 Emmanuel Paradis +## Copyright 2007-2008 Emmanuel Paradis ## This file is part of the R-package `ape'. ## See the file ../COPYING for licensing issues. @@ -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) } - structure(x[keep], class = "multiPhylo") + x[keep] }