-## 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.
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]
}