R/methods_peek.R
, R/ds_deque.R
, R/ds_heap.R
, and 1 more
peek-methods.Rd
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.
peek(obj) # S4 method for deque peek(obj) # S4 method for heap peek(obj) # S4 method for map peek(obj)
obj | the object to peek |
---|
returns the first element from obj
as list
#> <environment: 0x558eb1a904a8># 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)#> $a #> [1] 1 #># peeks into a \code{hashmap} h_map <- hashmap() h_map[letters] <- rnorm(length(letters)) peek(h_map)#> $t #> [1] 0.4861489 #> #> $w #> [1] 0.9463479 #> #> $x #> [1] 1.316826 #> #> $y #> [1] -0.29664 #> #> $z #> [1] -0.3872136 #># peeks into a \code{bimap} b_map <- bimap("integer", "integer") b_map[seq(10)] <- seq(10, 1) peek(b_map)#> $`1` #> [1] 10 #> #> $`2` #> [1] 9 #> #> $`3` #> [1] 8 #> #> $`4` #> [1] 7 #> #> $`5` #> [1] 6 #>