Search and return an element and remove it afterwards from the object. If the element is not found, signal an error.
ref_pop(.x, ...)ref_popleft(.x, ...)
# S3 method for Deque
ref_pop(.x, ...)
# S3 method for Deque
ref_popleft(.x, ...)
# S3 method for Container
ref_pop(.x, index, ...)
# S3 method for dict.table
ref_pop(.x, index, ...)
For Deque
the first (ref_popleft
) or last (ref_pop
) element of
the deque after it was removed.
For Container
the value at the given index after it was removed from
the Container
object. If index
is not found, an error is raised.
For dict.table
, returns the column at the given index
after it was
removed from the dict.table
. If column does not exist, an error is raised.
any R
object.
additional arguments to be passed to or from methods.
character
name or numeric
position of value to be popped
All functions work by reference, that is, the original object is altered.
ref_pop(.x)
tries to access specific values.
ref_popleft(.x)
pops first element of a Deque
.
peek()
# Deque
d = deque(1, 2, 3)
ref_pop(d)
ref_popleft(d)
if (FALSE) {
ref_pop(deque()) # pop at empty Deque
}
# Container
co = container(a = 1, b = 1:3, d = "foo")
ref_pop(co, "b")
ref_pop(co, 1)
if (FALSE) {
ref_pop(co, "x") # index 'x' not found
}
# dict.table
dit = dict.table(a = 1:3, b = 4:6)
ref_pop(dit, "a")
ref_pop(dit, 1)
if (FALSE) {
ref_pop(dit, "x") # index 'x' not found
}
Run the code above in your browser using DataLab