[Rcpp-commits] r3559 - in pkg/Rcpp: . inst inst/include/Rcpp/vector inst/unitTests

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Mar 30 01:40:49 CEST 2012


Author: edd
Date: 2012-03-30 01:40:49 +0200 (Fri, 30 Mar 2012)
New Revision: 3559

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/inst/NEWS
   pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
   pkg/Rcpp/inst/unitTests/runit.Vector.R
Log:
renamed has_element_called to containsElementNamed
updated unit test and changelog entry
added NEWS entry


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2012-03-29 18:30:51 UTC (rev 3558)
+++ pkg/Rcpp/ChangeLog	2012-03-29 23:40:49 UTC (rev 3559)
@@ -1,11 +1,11 @@
 2012-03-29  Dirk Eddelbuettel  <edd at debian.org>
 
-	* inst/unitTests/runit.Vector.R: unit test for has_element_called
+	* inst/unitTests/runit.Vector.R: unit test for containsElementNamed
 
 2012-03-29  Romain Francois  <romain at r-enthusiasts.com>
 
 	* inst/include/Rcpp/vector/Vector.h: Vector<> gains the
-	has_element_called method
+	containsElementNamed method to test for presence of named element
 
 2012-03-24  Romain Francois  <romain at r-enthusiasts.com>
 

Modified: pkg/Rcpp/inst/NEWS
===================================================================
--- pkg/Rcpp/inst/NEWS	2012-03-29 18:30:51 UTC (rev 3558)
+++ pkg/Rcpp/inst/NEWS	2012-03-29 23:40:49 UTC (rev 3559)
@@ -1,3 +1,8 @@
+0.9.11. 2012-xx-yy
+
+    o   New member function for vectors (and lists etc) containsElementNamed() 
+        which returns a boolean indicating if the given element name is present
+
 0.9.10  2012-02-16
 
     o   Rearrange headers so that Rcpp::Rcout can be used by RcppArmadillo et al

Modified: pkg/Rcpp/inst/include/Rcpp/vector/Vector.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-03-29 18:30:51 UTC (rev 3558)
+++ pkg/Rcpp/inst/include/Rcpp/vector/Vector.h	2012-03-29 23:40:49 UTC (rev 3559)
@@ -706,12 +706,13 @@
     /** 
      *  Does this vector have an element with the target name 
      */
-    bool has_element_called( const char* target ) const {
+    bool containsElementNamed( const char* target ) const {
         SEXP names = RCPP_GET_NAMES(m_sexp) ; 
         if( Rf_isNull(names) ) return false ;
         int n = Rf_length(names) ;
         for( int i=0; i<n; i++){
-            if( !strcmp( target, CHAR(STRING_ELT(names, i)) ) ) return true ;   
+            if( !strcmp( target, CHAR(STRING_ELT(names, i)) ) ) 
+                return true ;   
         }
         return false ;
     }

Modified: pkg/Rcpp/inst/unitTests/runit.Vector.R
===================================================================
--- pkg/Rcpp/inst/unitTests/runit.Vector.R	2012-03-29 18:30:51 UTC (rev 3558)
+++ pkg/Rcpp/inst/unitTests/runit.Vector.R	2012-03-29 23:40:49 UTC (rev 3559)
@@ -682,13 +682,13 @@
 	                '
 	          ),
 
-              "contains_element_named" = list(
+              "containsElementNamed" = list(
                 	signature(ls="list", ns="character"),
                 	'
                 	    List l(ls);
                             CharacterVector n(ns);
 
-			    return wrap(l.has_element_called(n[0]));
+			    return wrap(l.containsElementNamed(n[0]));
 	                '
               )
           )
@@ -1351,12 +1351,12 @@
     checkEquals( fun(), c(4L,4L), msg = "IntegerVector int init regression test" )
 }
 
-test.contains_element_named <- function() {
-    fun <- .rcpp.Vector$contains_element_named
+test.containsElementNamed <- function() {
+    fun <- .rcpp.Vector$containsElementNamed
 
     x <- list( foo = 2, bla = 1:10 )
 
-    checkEquals(fun(x, "foo"), TRUE, msg = "contains_element_names with element")
-    checkEquals(fun(x, "bar"), FALSE, msg = "contains_element_names without element")
-    checkEquals(fun(x, ""), FALSE, msg = "contains_element_names with empty element")
+    checkEquals(fun(x, "foo"), TRUE, msg = "containsElementNamed with element")
+    checkEquals(fun(x, "bar"), FALSE, msg = "containsElementNamed without element")
+    checkEquals(fun(x, ""), FALSE, msg = "containsElementNamed with empty element")
 }



More information about the Rcpp-commits mailing list