peek/peekback

Share:

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
peek(x, n = 1L)

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

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

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

peekback(x, n = 1L)

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

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

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

Arguments

x

A queue, stack, or deque.

n

The number of items to view.

Details

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

Value

Returns NULL; sub-elements are only printed.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
library(dequer)
s <- stack()
for (i in 1:3) push(s, i)

peek(s)
peekback(s)
peek(s, length(s))

## End(Not run)