Learn R Programming

dequer (version 2.0-2)

peeking: peek/peekback

Description

These methods are side-effect free. Note that unlike R's head() and tail(), the sub-objects are not actually created. They are merely printed to the terminal.

Usage

peek(x, n = 1L)

# S3 method for deque peek(x, n = 1L)

# S3 method for queue peek(x, n = 1L)

# S3 method for stack peek(x, n = 1L)

peekback(x, n = 1L)

# S3 method for deque peekback(x, n = 1L)

# S3 method for queue peekback(x, n = 1L)

# S3 method for stack peekback(x, n = 1L)

Arguments

x

A queue, stack, or deque.

n

The number of items to view.

Value

Returns NULL; sub-elements are only printed.

Details

View items from the front (peek()) or back (peekback()) of a queue, stack, or deque.

Examples

Run this code
# NOT RUN {
library(dequer)
s <- stack()
for (i in 1:3) push(s, i)

peek(s)
peekback(s)
peek(s, length(s))
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab