x <- as.integer64(sample(c(NA, 0:9)))
y <- as.integer64(sample(c(NA, 1:9), 10, TRUE))
hashfun(y)
hx <- hashmap(x)
hy <- hashmap(y)
ls(hy)
hashpos(hy, x)
hashrev(hx, y)
hashfin(hy, x)
hashrin(hx, y)
hashdup(hy)
hashuni(hy)
hashuni(hy, keep.order=TRUE)
hashmapuni(y)
hashupo(hy)
hashupo(hy, keep.order=TRUE)
hashmapupo(y)
hashtab(hy)
hashmaptab(y)
if (FALSE) {
message("explore speed given size of the hasmap in 2^hashbits and size of the data")
message("more hashbits means more random access and less collisions")
message("i.e. more data means less random access and more collisions")
bits <- 24
b <- seq(-1, 0, 0.1)
tim <- matrix(NA, length(b), 2, dimnames=list(b, c("bits", "bits+1")))
for (i in 1:length(b)) {
n <- as.integer(2^(bits+b[i]))
x <- as.integer64(sample(n))
tim[i, 1] <- repeat.time(hashmap(x, hashbits=bits))[3]
tim[i, 2] <- repeat.time(hashmap(x, hashbits=bits+1))[3]
print(tim)
matplot(b, tim)
}
message("we conclude that n*sqrt(2) is enough to avoid collisions")
}
Run the code above in your browser using DataLab