Deques are a generalization of stacks and queues typically
with methods to add, delete and access elements at both sides of the
underlying data sequence. As such, the Deque can also be used to mimic
both stacks and queues. For the standard S3 interface, see deque()
.
container::Iterable
-> container::Container
-> Deque
Inherited methods
container::Iterable$iter()
container::Container$add()
container::Container$at()
container::Container$at2()
container::Container$clear()
container::Container$count()
container::Container$delete()
container::Container$delete_at()
container::Container$discard()
container::Container$discard_at()
container::Container$empty()
container::Container$get_compare_fun()
container::Container$has()
container::Container$has_name()
container::Container$initialize()
container::Container$is_empty()
container::Container$length()
container::Container$names()
container::Container$peek_at()
container::Container$peek_at2()
container::Container$pop()
container::Container$print()
container::Container$remove()
container::Container$rename()
container::Container$replace()
container::Container$replace_at()
container::Container$size()
container::Container$type()
container::Container$update()
container::Container$values()
addleft()
Add element to left side of the Deque
.
Deque$addleft(value, name = NULL)
value
value of ANY
type to be added to the Deque
.
name
character
optional name attribute of the value.
the Deque
object.
peek()
Peek at last element of the Deque
.
Deque$peek(default = NULL)
default
returned default value if Deque
is empty.
element 'peeked' on the right
peekleft()
Peek at first element of the Deque
.
Deque$peekleft(default = NULL)
default
returned default value if Deque
is empty.
element 'peeked' on the left
popleft()
Delete and return element from the left side of the Deque()
.
Deque$popleft()
element 'popped' from the left side of the Deque()
the Deque()
object.
rotate()
Rotate all elements n
steps to the right. If n is
negative, rotate to the left.
Deque$rotate(n = 1L)
n
integer
number of steps to rotate
returns the Deque()
object.
clone()
The objects of this class are cloneable with this method.
Deque$clone(deep = FALSE)
deep
Whether to make a deep clone.
This class inherits from class Container()
and extends it by
popleft
and peek
methods, and reverse and rotate functionality.
Container()
, deque()
d = Deque$new(1, 2, s = "a", v = 1:3)
d$addleft(0)
d$peekleft()
d$peek()
d$popleft()
d$rev()
d$rotate()
d$rotate(2)
d$rotate(-3)
Run the code above in your browser using DataLab