Reverse an rstack
Returns a reversed version of an rstack, where the old last element (generally inaccessible) is now the top (and thus now accessible).
## S3 method for class 'rstack' rev(x)
rstack to reverse.
This method runs in O(N) in the size of the rstack, though it works behind-the-scenes
for efficiency by converting the input stack
to a list, reversing the list, and building the result as a new rstack. The original is thus
left alone, preserving O(1) amortized time for the original (assuming the "cost" of reversing
is charged to the newly created stack) at the cost of additional memory usage. But,
if the stack is not being used in a preserved manner, e.g.
s <- rev(s), the garbage collector
will be free to clean up the original data if it is no longer usable.
a reversed version of the rstack.
as.list.rstack for converting an rstack to a list.
1 2 3 4 5 6 7 8
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.