expandingList: Fast expanding list.

Description Usage Arguments Details Value Examples

View source: R/data-structures.R

Description

expandingList is a fast implementation of a list that can be dynamically appended to and turned into a standard R list.

Usage

1
expandingList(capacity = 10, envir = emptyenv())

Arguments

capacity

Initial list capacity or length.

envir

Environment.

Details

expandingList is a closure that enables modification in place. It serves as an object in R.

The code is copied from Jan Kanis at http://stackoverflow.com/a/32870310.

Value

A closure named expandingList with functions

Examples

1
2
3
4
5
g <- expandingList(5)  ## expandingList of length 5

for (i in 1:10) g$add(i)  ## append to list without explicitly expanding

identical(1:10, unlist(g$as.list()))  ## TRUE

curtisalexander/CRAmisc documentation built on May 12, 2017, 2:22 p.m.