peeking: peek/peekback

peekingR Documentation

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 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

## 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)


wrathematics/dequer documentation built on March 17, 2022, 6:38 p.m.