[Phylobase-commits] r855 - pkg/src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 9 22:29:44 CET 2014


Author: francois
Date: 2014-03-09 22:29:44 +0100 (Sun, 09 Mar 2014)
New Revision: 855

Modified:
   pkg/src/checkPhylo4.cpp
Log:
removed use of iterator that made R crash with phylotorture.

Modified: pkg/src/checkPhylo4.cpp
===================================================================
--- pkg/src/checkPhylo4.cpp	2014-03-09 21:29:06 UTC (rev 854)
+++ pkg/src/checkPhylo4.cpp	2014-03-09 21:29:44 UTC (rev 855)
@@ -1,3 +1,4 @@
+// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
 
 #include <Rcpp.h>
 #include <iostream>     // std::cout
@@ -47,10 +48,12 @@
 //[[Rcpp::export]]
 std::vector<int> tabulateTips (Rcpp::IntegerVector ances) {
 // tabulates ancestor nodes that are not the root.
-    int n = ances.size();
+    int n = Rcpp::max(ances);
     std::vector<int> ans(n);
-    for (Rcpp::IntegerVector::iterator it = ances.begin(); it != ances.end(); ++it) {
-     	if (*it > 0) ans[*it - 1]++;
+    for (int i=0; i < n; i++) {
+        if (i > 0) {
+            ans[i - 1]++;
+        }
     }
     return ans;
 }



More information about the Phylobase-commits mailing list