Hash: Hash object

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/Hash.R

Description

Hash object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Hash(keys=NULL,values=NULL)
Hash.key.multi(x,...,sep = " ")
## S3 replacement method for class 'Hash'
x[...,sep = " "] <- value
## S3 method for class 'Hash'
x[...,sep = " "]
## S3 method for class 'Hash'
print(x,...)
## S3 method for class 'Hash'
length(x)

Arguments

x

A Hash object, using Hash function.

values

A vector with the values you want to store.

value

The values you want to store.

keys

A vector with keys for each values.

sep

A character value using to separate the multiple keys for each value.

...

One or more values for access or find elements.

Details

If you want to delete a key just insert the global variable "Rfast:::delete".

Hash: Create Hash object where every key has a value. Specify the type from the beggining (for speed). Use the argument "type" with one of the values "new.env, logical, character, integer, numeric". Hash.key.multi: search if key exists. If the keys are multiple, then use the argument "substr" to search inside each multiple for the specific key.

Value

A Hash object.

Author(s)

Manos Papadakis

R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.

See Also

hash.list, hash.find

Examples

1
2
3
4
5
6
7
8
9
x <- Hash(rnorm(10),sample(1:10))

x[1,2,13] <- 0.1234 # insert value using multi key. the same as x["1 2 13"] <- 0.1234
x[1,2,3] <- 15 # insert value using multi key. the same as x["1 2 3"] <- 15

Hash.key.multi(x,"1")
x # print Hash object using S3 generic
#x[1,2,3] <- Rfast:::delete # delete multi key. the same as x["1 2 3"] <- NULL
length(x)

Example output

Loading required package: Rcpp
Loading required package: RcppZiggurat
[1] "1 2 13"
<Hash> contains  12  keys-values pairs
-0.456661846640394   :  8 
0.379696444099435    :  7 
-0.198649730141455   :  1 
2.37925577149445     :  9 
-0.0542918696546573  :  2 
0.648575460664915    :  10 
-0.814811100172361   :  3 
0.128856285009405    :  4 
1 2 3                :  15 
1.20660164900703     :  5 
0.102978923464682    :  6 
1 2 13               :  0.1234 
[1] 12

Rfast documentation built on Dec. 11, 2021, 9:59 a.m.