Learn R Programming

datastructures (version 0.2.9)

erase: Erase an entry from a map

Description

Erase a vector of key-value pair from a map object.

Usage

erase(obj, key, value)

# S4 method for map,vector,missing erase(obj, key)

# S4 method for bimap,missing,vector erase(obj, value)

# S4 method for multimap,vector,vector erase(obj, key, value)

# S4 method for multimap,vector,list erase(obj, key, value)

# S4 method for multimap,vector,ANY erase(obj, key, value)

Arguments

obj

the object to pop an element from

key

a vector of keys that should be removed

value

optionally a list of values needs to be supplied for some data structures such as multimaps if a single key-value pair should removed. If not provided removes all key-value pairs with a specific key.

Value

returns obj with removed values

Examples

Run this code
# NOT RUN {
 # erases keys from a hashmap or bimap
 h_map <- hashmap()
 h_map[letters] <- rnorm(length(letters))
 h_map <- erase(h_map, "a")
 h_map <- erase(h_map, letters[2:5])

 # erases keys from a multimap
 m_map <- multimap()
 m_map[c("a", "a", "a", "b", "b", "c")] <- rep(1:2, 3)
 m_map <- erase(m_map, "a")
 m_map <- erase(m_map, "b", 1)

# }

Run the code above in your browser using DataLab