subsetting_hashtables: Subsetting 'hashset's and 'hashmap's

Description Usage Arguments Value Author(s)

Description

Subsetting operators `[[` and `[` for hashsets and hashmaps provide an equivalent synthax for the basic read/write operations performed by insert(), delete() and query().

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## S3 method for class 'r2r_hashmap'
x[[i]]

## S3 method for class 'r2r_hashmap'
x[i]

## S3 replacement method for class 'r2r_hashmap'
x[[i]] <- value

## S3 replacement method for class 'r2r_hashmap'
x[i] <- value

## S3 method for class 'r2r_hashset'
x[[i]]

## S3 method for class 'r2r_hashset'
x[i]

## S3 replacement method for class 'r2r_hashset'
x[[i]] <- value

## S3 replacement method for class 'r2r_hashset'
x[i] <- value

Arguments

x

an hashset or hashmap.

i

for `[[`-subsetting, an arbitrary R object, the key to be queried or inserted/deleted from the hash tables. For `[`-subsetting, a list or an atomic vector whose individual elements correspond to the keys.

value

for `[[`-subsetting: TRUE or FALSE if x is an hashset, an arbitrary R object if x is an hashmap. In the case of hashsets, setting a key's value to TRUE and FALSE is equivalent to inserting and deleting, respectively, such key from the set. For `[`-subsetting, value must be a list or an atomic vector of the same length of i, whose individual elements are the values associated to the corresponding keys in the hash table.

Value

the replacement forms ([[<- and [<-) always return value. `[[` returns TRUE or FALSE if x is an hashset, an arbitrary R object if x is an hashmap and i is a valid key; when i is not a key, the behaviour for hashmaps depends on the value of on_missing_key(x). The `[` operator returns a list of the same length of i, whose k-th element is given by x[[ i[[k]] ]] (the remark on missing keys for hashmaps applies also here).

Author(s)

Valerio Gherardi


r2r documentation built on July 6, 2021, 5:12 p.m.