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

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Jun 11 15:16:43 CEST 2010


Author: romain
Date: 2010-06-11 15:16:43 +0200 (Fri, 11 Jun 2010)
New Revision: 1519

Modified:
   pkg/Rcpp/inst/include/Rcpp/algo.h
   pkg/Rcpp/inst/include/Rcpp/operators/VectorOperators.h
Log:
some polishing , and added any

Modified: pkg/Rcpp/inst/include/Rcpp/algo.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/algo.h	2010-06-11 13:02:21 UTC (rev 1518)
+++ pkg/Rcpp/inst/include/Rcpp/algo.h	2010-06-11 13:16:43 UTC (rev 1519)
@@ -157,7 +157,18 @@
 }
 
 
+template <typename T>
+bool any( const T& t){
+	bool seen_na = false ;
+	int n = t.size() ;
+	for( int i=0 ; i<n ; i++){
+		if( t[i] == TRUE ) return TRUE ;
+		if( t[i] == NA_LOGICAL ) seen_na = true;
+	}
+	return seen_na ? NA_LOGICAL : FALSE ;
+}
 
+
 }
 
 #endif

Modified: pkg/Rcpp/inst/include/Rcpp/operators/VectorOperators.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/operators/VectorOperators.h	2010-06-11 13:02:21 UTC (rev 1518)
+++ pkg/Rcpp/inst/include/Rcpp/operators/VectorOperators.h	2010-06-11 13:16:43 UTC (rev 1519)
@@ -38,6 +38,8 @@
 			NA_LOGICAL : ( lhs[i] < rhs[i] ) ;
 	}
 	
+	inline int size() const { return lhs.size() ; }
+	
 	class iterator {
 	public:
 		typedef int difference_type ;



More information about the Rcpp-commits mailing list