Learn R Programming

collections (version 0.2.5)

Deque: Double Ended Queue

Description

The Deque function creates a double ended queue.

Usage

Deque(items = NULL)

Arguments

items

a list of items

Details

Following methods are exposed:

.$push(item)
.$pushleft(item)
.$pop()
.$popleft()
.$peek()
.$peekleft()
.$extend(q)
.$extendleft(q)
.$remove(item)
.$clear()
.$size()
.$as_list()
.$print()
  • item: any R object

  • q: a Deque object

See Also

DequeL

Examples

Run this code
# NOT RUN {
q <- Deque()
q$push("foo")
q$push("bar")
q$pushleft("baz")
q$pop()  # bar
q$popleft()  # baz

q <- Deque(list("foo", "bar"))
q$push("baz")$pushleft("bla")
# }

Run the code above in your browser using DataLab