24 #ifndef RCPP__HASH__INDEX_HASH_H
25 #define RCPP__HASH__INDEX_HASH_H
27 #if ( defined(HASH_PROFILE) && defined(__APPLE__) )
29 #include <mach/mach_time.h>
30 #define ABSOLUTE_TIME mach_absolute_time
31 #define RCPP_PROFILE_TIC start = ABSOLUTE_TIME() ;
32 #define RCPP_PROFILE_TOC end = ABSOLUTE_TIME() ;
33 #define RCPP_PROFILE_RECORD(name) profile_data[#name] = end - start ;
35 #define RCPP_PROFILE_TIC
36 #define RCPP_PROFILE_TOC
37 #define RCPP_PROFILE_RECORD(name)
39 #define RCPP_USE_CACHE_HASH
45 #define RCPP_HASH(X) (3141592653U * ((uint32_t)(X)) >> (32 - k))
62 while(
m < desired ){
m *= 2 ;
k++ ; }
63 #ifdef RCPP_USE_CACHE_HASH
86 int* res = LOGICAL(
result) ;
87 for(
int i=0; i<
n; i++) res[i] = !
add_value(i) ;
92 inline SEXP
lookup(
const T& vec)
const {
102 return get_index(val) !=
static_cast<uint32_t
>(NA_INTEGER);
112 for(
int i=0, j=0; j<
size_; i++){
121 #ifdef RCPP_USE_CACHE_HASH
124 std::vector<int>
data ;
128 mutable std::map<std::string,int> profile_data ;
129 mutable uint64_t start ;
130 mutable uint64_t end ;
133 template <
typename T>
137 SEXP res = Rf_allocVector(INTSXP, n_) ;
142 int *v = INTEGER(res) ;
146 for(
int i=0; i<n_; i++) v[i] =
get_index( vec[i] ) ;
156 return wrap( profile_data ) ;
163 return ! internal::NAEquals<STORAGE>()(lhs, rhs);
172 if (addr ==
static_cast<uint32_t
>(
m)) {
190 if (
src[
data[addr] - 1] == value)
193 if (addr ==
static_cast<uint32_t
>(
m)) addr = 0;
215 if (val == 0.0) val = 0.0;
216 if (internal::Rcpp_IsNA(val)) val = NA_REAL;
217 else if (internal::Rcpp_IsNaN(val)) val = R_NaN;
219 addr =
RCPP_HASH(val_u.u[0] + val_u.u[1]);
225 intptr_t val = (intptr_t) value;
227 #if (defined _LP64) || (defined __LP64__) || (defined WIN64)
228 addr =
RCPP_HASH((val & 0xffffffff) ^ (val >> 32));
#define RCPP_PROFILE_RECORD(name)
SEXP lookup(const VECTOR &vec) const
bool contains(STORAGE val) const
bool not_equal(const STORAGE &lhs, const STORAGE &rhs)
Vector< RTYPE > keys() const
uint32_t get_addr(STORAGE value) const
SEXP lookup__impl(const T &vec, int n_) const
traits::storage_type< RTYPE >::type STORAGE
SEXP lookup(const T &vec) const
LogicalVector fill_and_get_duplicated()
uint32_t get_index(STORAGE value) const
#define RCPP_DEBUG_2(fmt, M1, M2)
#define DEMANGLE(__TYPE__)
no_init_vector no_init(R_xlen_t size)
IntegerVector table(const VectorBase< RTYPE, NA, T > &x)
SEXP wrap(const Date &date)
attribute_hidden int * get_cache(int n)