[Rcpp-commits] r4066 - in pkg/Rcpp: inst/include/Rcpp/hash src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Dec 4 00:31:24 CET 2012


Author: romain
Date: 2012-12-04 00:31:24 +0100 (Tue, 04 Dec 2012)
New Revision: 4066

Modified:
   pkg/Rcpp/inst/include/Rcpp/hash/hash_impl.h
   pkg/Rcpp/src/fastmatch.c
Log:
clean the hash data structure

Modified: pkg/Rcpp/inst/include/Rcpp/hash/hash_impl.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/hash/hash_impl.h	2012-12-03 23:12:19 UTC (rev 4065)
+++ pkg/Rcpp/inst/include/Rcpp/hash/hash_impl.h	2012-12-03 23:31:24 UTC (rev 4066)
@@ -27,10 +27,8 @@
 #endif    
 
     typedef struct hash {
-      int m, k, els, type;
+      int m, k  ;
       void *src;
-      SEXP parent;
-      struct hash *next;
       int ix[1];
     } hash_t;
 

Modified: pkg/Rcpp/src/fastmatch.c
===================================================================
--- pkg/Rcpp/src/fastmatch.c	2012-12-03 23:12:19 UTC (rev 4065)
+++ pkg/Rcpp/src/fastmatch.c	2012-12-03 23:31:24 UTC (rev 4066)
@@ -41,7 +41,6 @@
 
 /* free the hash table (and all chained hash tables as well) */
 void free_hash(hash_t *h) {
-  if (h->next) free_hash(h->next);
   free(h);
 }
 
@@ -156,44 +155,3 @@
   return NA_INTEGER;
 }
 
-/* the only externally visible function to be called from R */
-SEXP simon_fmatch(SEXP x, SEXP y) {
-  SEXPTYPE type = TYPEOF(y) ;
-  
-  hash_t* h = new_hash(DATAPTR(y), LENGTH(y));
-  h->type = type;
-  h->parent = y;
-
-  int i, n = LENGTH(y);
-  if (type == INTSXP)
-	for(i = 0; i < n; i++)
-	  add_hash_int(h, i);
-  else if (type == REALSXP)
-	for(i = 0; i < n; i++)
-	  add_hash_real(h, i);
-  else
-	for(i = 0; i < n; i++)
-	  add_hash_ptr(h, i);
-    
-  n = LENGTH(x) ;
-    SEXP r = allocVector(INTSXP, n);
-    int *v = INTEGER(r);
-    if (type == INTSXP) {
-      int *k = INTEGER(x);
-      for (i = 0; i < n; i++)
-	  v[i] = get_hash_int(h, k[i]);
-    } else if (type == REALSXP) {
-      double *k = REAL(x);
-      for (i = 0; i < n; i++)
-	  v[i] = get_hash_real(h, k[i]);
-    } else {
-      SEXP *k = (SEXP*) DATAPTR(x);
-      for (i = 0; i < n; i++)
-	  v[i] = get_hash_ptr(h, k[i]);
-    }
-  
-    free_hash( h ) ;
-    return r;
-  
-}
-



More information about the Rcpp-commits mailing list