sep: sep

View source: R/sep.r

sepR Documentation

sep

Description

Spliot one object (queue/stack/deque) into two of the same type. NOTE: this function operates via side-effects AND has a return.

Usage

sep(x, k)

Arguments

x

A deque.

k

Index to split the deque at.

Details

Operates via side-effects ALTHOUGH THERE IS A NON-NULL RETURN; see examples for clarification on usage.

The split occurs after index k. So if the input x has, say, elements 1 to n, then after running sep(x, k), x will have elements 1 to k, and the return will have values k+1, k+2, ..., n.

Value

A deque, stack, or queue (depending on the input)

Examples

## Not run: 
library(dequer)
s <- stack()
for (i in 1:5) push(s, i)

### Split s into 2 stacks holding: (s) the first 3, and (s_last_2) last 2 elements
s_last_2 <- sep(s, 3)

str(s)
str(s_last_5)

## End(Not run)


dequer documentation built on March 18, 2022, 5:45 p.m.