peek-methods: Have a look at the first element from an object without...

Description Usage Arguments Value Examples

Description

Peeks into an object, i.e. takes the first element and returns it without removing it from the object. The data structure that has a peek method usually uses some sort of priority of its elements.

Usage

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

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

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

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

Arguments

obj

the object to peek

Value

returns the first element from obj as list

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
 # peeks into a queue
 q <- queue()
 q <- insert(q, list(environment(), data.frame(a=1)))
 peek(q)

 # peeks into a fibonacci heap
 b_heap <- binomial_heap()
 b_heap <- insert(b_heap, letters[seq(3)], list(1, diag(3), rnorm(2)))
 peek(b_heap)

 # peeks into a \code{hashmap}
 h_map <- hashmap()
 h_map[letters] <- rnorm(length(letters))
 peek(h_map)

 # peeks into a \code{bimap}
 b_map <- bimap("integer", "integer")
 b_map[seq(10)] <- seq(10, 1)
 peek(b_map)

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