erase-methods: Erase an entry from a map

Description Usage Arguments Value Examples

Description

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

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
erase(obj, key, value)

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

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

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

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

## S4 method for signature '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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
 # 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)

datastructures documentation built on Aug. 10, 2020, 5:08 p.m.