pop-methods: Pop a single element from an object

Description Usage Arguments Value Examples

Description

Remove and return the first element from a data structure that has a priority, such as a heap or deque.

Usage

1
2
3
4
5
6
7
pop(obj)

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

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

Arguments

obj

the object to pop an element from

Value

returns the first element from obj as list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 # pops from a queue
 q <- queue()
 q <- insert(q, list(environment(), data.frame(a=1)))
 pop(q)

 # pops from a stack
 s <- stack()
 s <- insert(s, list(environment(), data.frame(a=1)))
 pop(s)

 # pops from a fibonacci heap
 b_heap <- binomial_heap()
 b_heap <- insert(b_heap, letters[seq(3)], list(1, diag(3), rnorm(2)))
 pop(b_heap)

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