mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Add Stack ref class
This commit is contained in:
@@ -54,6 +54,7 @@ Collate:
|
||||
'reactives.R'
|
||||
'run-url.R'
|
||||
'server.R'
|
||||
'stack.R'
|
||||
'shiny.R'
|
||||
'shinyui.R'
|
||||
'shinywrappers.R'
|
||||
|
||||
28
R/stack.R
Normal file
28
R/stack.R
Normal file
@@ -0,0 +1,28 @@
|
||||
Stack <- setRefClass(
|
||||
'Stack',
|
||||
fields = list(
|
||||
.stack = 'list'
|
||||
),
|
||||
methods = list(
|
||||
push = function(obj) {
|
||||
.stack <<- c(.stack, list(obj))
|
||||
invisible(.self)
|
||||
},
|
||||
pop = function() {
|
||||
len <- length(.stack)
|
||||
if (len == 0)
|
||||
return(NULL)
|
||||
obj <- .stack[[len]]
|
||||
.stack <<- .stack[-len]
|
||||
obj
|
||||
},
|
||||
peek = function() {
|
||||
len <- length(.stack)
|
||||
if (len == 0) return(NULL)
|
||||
.stack[[len]]
|
||||
},
|
||||
size = function() {
|
||||
length(.stack)
|
||||
}
|
||||
)
|
||||
)
|
||||
Reference in New Issue
Block a user