deque creates a double ended queue.

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

Examples

q <- deque()
q$push("foo")
q$push("bar")
q$pushleft("baz")
q$pop()  # bar
#> [1] "bar"
q$popleft()  # baz
#> [1] "baz"

q <- deque(list("foo", "bar"))
q$push("baz")$pushleft("bla")