Low-level nested map to store key-value data with inherited structure
Source:R/class010-bids_map.R
BIDSMap.Rd
Low-level nested map to store key-value data with inherited structure
Examples
root_map <- BIDSMap()
root_map$key1 <- 1
root_map$key2 <- 2
names(root_map)
#> [1] "key2" "key1"
child_map <- BIDSMap(parent = root_map)
child_map$key3 <- 3
names(child_map)
#> [1] "key1" "key2" "key3"
child_map$key1
#> [1] 1
child_map$key2
#> [1] 2
# mask key2
child_map$key2 <- "a"
child_map
#> <bidsr::map 70558fa5-51d3-4c88-9d97-03666319b7b7>
#> (parent: 20362c73-929b-40d6-a109-f0f324eb0e14)
#> [key2, key3]
#> (Inherited) [key1]
root_map$key2
#> [1] 2
child_map$key2
#> [1] "a"
# nested maps
grand_child <- BIDSMap(parent = child_map)
# value comes from child map
grand_child$key2
#> [1] "a"
# remove key2 from child map
child_map@impl$remove("key2")
# key2 is from root map now
grand_child$key2
#> [1] 2