clear-methods: Remove all elements from a datastructure

Description Usage Arguments Examples

Description

Removes every element that is stored in a data structure and resets everything.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
clear(obj)

## S4 method for signature 'deque'
clear(obj)

## S4 method for signature 'heap'
clear(obj)

## S4 method for signature 'map'
clear(obj)

Arguments

obj

the object to clear

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
 # clears a multimap
 m_map <- multimap()
 m_map <- insert(m_map, c("a", "b"), 1:2)
 m_map <- insert(m_map, c("a", "b"), list(1, list(a=1)))
 m_map <- clear(m_map)


 # clears a heap
 f_heap <- fibonacci_heap("integer")
 f_heap <- insert(f_heap, 1:2, 1:2)
 f_heap[3:4] <-  list(1, list(a=1))
 f_heap <- clear(f_heap)

 # clears a \code{deque}
 s <- stack()
 s <- insert(s, list(1, vector(), list(3), data.frame(rnorm(3))))
 s <- clear(s)

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