Learn R Programming

dequer (version 2.0-2)

pushing: push/pushback

Description

Add items to the front of a stack or deque via pop(). Add items to the back of a queue or deque via popback().

Usage

push(x, data)

# S3 method for deque push(x, data)

# S3 method for stack push(x, data)

pushback(x, data)

# S3 method for deque pushback(x, data)

# S3 method for queue pushback(x, data)

Arguments

x

A queue, stack, or deque.

data

R object to insert at the front of the deque/stack.

Value

Returns NULL; insertion operates via side-effects.

Details

Operates via side-effects; see examples for clarification on usage.

Examples

Run this code
# NOT RUN {
library(dequer)

### A simple queue example
q <- queue()
for (i in 1:3) pushback(q, i)

str(q)

### A simple stack example
s <- stack()
for (i in 1:3) push(s, i)

str(s)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab