[Rcpp-commits] r1169 - in pkg/Rcpp/inst: . include

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed May 5 12:08:33 CEST 2010


Author: romain
Date: 2010-05-05 12:08:33 +0200 (Wed, 05 May 2010)
New Revision: 1169

Modified:
   pkg/Rcpp/inst/ChangeLog
   pkg/Rcpp/inst/include/RcppCommon.h
Log:
+ Rcpp::any_if

Modified: pkg/Rcpp/inst/ChangeLog
===================================================================
--- pkg/Rcpp/inst/ChangeLog	2010-05-05 09:56:35 UTC (rev 1168)
+++ pkg/Rcpp/inst/ChangeLog	2010-05-05 10:08:33 UTC (rev 1169)
@@ -1,9 +1,9 @@
-2010-05-06  Romain Francois <romain at r-enthusiasts.com>
+2010-05-05  Romain Francois <romain at r-enthusiasts.com>
 
 	* inst/include/Rcpp/S4.h: S4 gains a "is" method to identify if an object 
 	is of a given S4 class, following Doug's advice in lme4a
 	
-	* inst/include/RcppCommon.h: new STL-like algorithm Rcpp::any 
+	* inst/include/RcppCommon.h: new STL-like algorithms Rcpp::any and Rcpp::any_if
 
 2010-05-04  Romain Francois <romain at r-enthusiasts.com>
 

Modified: pkg/Rcpp/inst/include/RcppCommon.h
===================================================================
--- pkg/Rcpp/inst/include/RcppCommon.h	2010-05-05 09:56:35 UTC (rev 1168)
+++ pkg/Rcpp/inst/include/RcppCommon.h	2010-05-05 10:08:33 UTC (rev 1169)
@@ -236,6 +236,16 @@
     return false;
 } ;             
 
+/**
+ * stl-like algorithm to identify if the predicate is true for any
+ * of the objects in the range
+ */
+template<class InputIterator, class Predicate>
+bool any_if( InputIterator first, InputIterator last, Predicate pred ){
+  for ( ; first!=last ; first++ ) if ( pred(*first) ) return true ;
+  return false;
 }
 
+}
+
 #endif



More information about the Rcpp-commits mailing list