├── .Rbuildignore ├── .github ├── .gitignore └── workflows │ ├── check-standard.yaml │ └── test-coverage.yaml ├── .gitignore ├── DESCRIPTION ├── NAMESPACE ├── NEWS.md ├── R ├── 0-ContainerR6.R ├── 0-ContainerS3.R ├── 0-DequeR6.R ├── 0-DequeS3.R ├── 0-DictR6.R ├── 0-DictS3.R ├── 0-IteratorR6.R ├── 0-IteratorS3.R ├── 0-SetR6.R ├── 0-SetS3.R ├── 0-dict.table.R ├── GroupGenericMath.R ├── GroupGenericSummary.R ├── Ops-arithmetic.R ├── Ops-compare.R ├── Ops-extract.R ├── Ops-logic.R ├── Ops-replace.R ├── add.R ├── addleft.R ├── all.equal.R ├── at.R ├── at2.R ├── clear.R ├── clone.R ├── container-deprecated.R ├── container-pkg.R ├── count.R ├── delete.R ├── delete_at.R ├── discard.R ├── discard_at.R ├── format.R ├── get_label.R ├── has.R ├── has_name.R ├── is_empty.R ├── options.R ├── peek.R ├── peek_at.R ├── peek_at2.R ├── pop.R ├── rename.R ├── replace.R ├── replace_at.R ├── rev.R ├── rotate.R ├── unpack.R ├── update.R ├── utils_index.R └── utils_misc.R ├── README.Rmd ├── README.md ├── TODO ├── _pkgdown.yml ├── docs ├── 404.html ├── apple-touch-icon-120x120.png ├── apple-touch-icon-152x152.png ├── apple-touch-icon-180x180.png ├── apple-touch-icon-60x60.png ├── apple-touch-icon-76x76.png ├── apple-touch-icon.png ├── articles │ ├── code-development.html │ ├── code-development_files │ │ └── header-attrs-2.11 │ │ │ └── header-attrs.js │ ├── container.html │ ├── container_files │ │ └── header-attrs-2.11 │ │ │ └── header-attrs.js │ ├── deque-set-dict.html │ ├── deque-set-dict_files │ │ └── header-attrs-2.11 │ │ │ └── header-attrs.js │ ├── index.html │ ├── manage-data-columns.html │ ├── manage-data-columns_files │ │ ├── figure-html │ │ │ ├── benchmark1-1.png │ │ │ ├── benchmark2-1.png │ │ │ └── benchmark3-1.png │ │ └── header-attrs-2.11 │ │ │ └── header-attrs.js │ ├── parameter-list.html │ ├── parameter-list_files │ │ └── header-attrs-2.11 │ │ │ └── header-attrs.js │ ├── reference-semantics.html │ ├── reference-semantics_files │ │ └── header-attrs-2.11 │ │ │ └── header-attrs.js │ ├── v01-interactive-usage.html │ ├── v02-code-development.html │ ├── v03-parameter-list.html │ ├── v04-manage-data-columns.html │ ├── v04-manage-data-columns_files │ │ └── figure-html │ │ │ ├── benchmark1-1.png │ │ │ ├── benchmark2-1.png │ │ │ └── benchmark3-1.png │ ├── v05-deque-set-dict.html │ └── v06-reference-semantics.html ├── authors.html ├── bootstrap-toc.css ├── bootstrap-toc.js ├── deps │ ├── bootstrap-5.3.1 │ │ ├── bootstrap.bundle.min.js │ │ ├── bootstrap.bundle.min.js.map │ │ └── bootstrap.min.css │ ├── bootstrap-toc-1.0.1 │ │ └── bootstrap-toc.min.js │ ├── clipboard.js-2.0.11 │ │ └── clipboard.min.js │ ├── data-deps.txt │ ├── font-awesome-6.5.2 │ │ ├── css │ │ │ ├── all.css │ │ │ ├── all.min.css │ │ │ ├── v4-shims.css │ │ │ └── v4-shims.min.css │ │ └── webfonts │ │ │ ├── fa-brands-400.ttf │ │ │ ├── fa-brands-400.woff2 │ │ │ ├── fa-regular-400.ttf │ │ │ ├── fa-regular-400.woff2 │ │ │ ├── fa-solid-900.ttf │ │ │ ├── fa-solid-900.woff2 │ │ │ ├── fa-v4compatibility.ttf │ │ │ └── fa-v4compatibility.woff2 │ ├── headroom-0.11.0 │ │ ├── headroom.min.js │ │ └── jQuery.headroom.min.js │ ├── jquery-3.6.0 │ │ ├── jquery-3.6.0.js │ │ ├── jquery-3.6.0.min.js │ │ └── jquery-3.6.0.min.map │ └── search-1.0.0 │ │ ├── autocomplete.jquery.min.js │ │ ├── fuse.min.js │ │ └── mark.min.js ├── docsearch.css ├── docsearch.js ├── favicon-16x16.png ├── favicon-32x32.png ├── favicon.ico ├── index.html ├── katex-auto.js ├── lightswitch.js ├── link.svg ├── logo.png ├── news │ └── index.html ├── pkgdown.css ├── pkgdown.js ├── pkgdown.yml ├── reference │ ├── !=.Container.html │ ├── &.Dict.html │ ├── &.Set.html │ ├── +.Container.html │ ├── +.Deque.html │ ├── +.Dict.html │ ├── +.Set.html │ ├── -.Container.html │ ├── -.Deque.html │ ├── -.Dict.html │ ├── -.Set.html │ ├── ==.Container.html │ ├── Container.html │ ├── ContainerS3.html │ ├── Deque.html │ ├── Dict.html │ ├── Iterable.html │ ├── Iterator.html │ ├── OpsArithmetic.html │ ├── OpsCompare.html │ ├── OpsExtract.html │ ├── OpsLogic.html │ ├── OpsReplace.html │ ├── OrderedSet.html │ ├── Rplot001.png │ ├── Set.html │ ├── [.Container.html │ ├── [[.Container.html │ ├── add.Container.html │ ├── add.Dict.html │ ├── add.dict.table.html │ ├── add.html │ ├── addleft.Deque.html │ ├── addleft.html │ ├── as.cont.html │ ├── as.container.html │ ├── as.deque.html │ ├── as.dict.html │ ├── as.dict.table.data.table.html │ ├── as.dict.table.html │ ├── as.list.Container.html │ ├── as.orderedset.html │ ├── as.set.html │ ├── at.Container.html │ ├── at.dict.table.html │ ├── at.html │ ├── at2.Container.html │ ├── at2.dict.table.html │ ├── at2.html │ ├── begin.html │ ├── cbind.dict.table.html │ ├── clear.Container.html │ ├── clear.dict.table.html │ ├── clear.html │ ├── clone.Container.html │ ├── clone.dict.table.html │ ├── clone.html │ ├── cont.html │ ├── container-deprecated.html │ ├── container-pkg.html │ ├── container_options.html │ ├── count.Container.html │ ├── count.Set.html │ ├── count.html │ ├── delete.Container.html │ ├── delete.html │ ├── delete_at.Container.html │ ├── delete_at.dict.table.html │ ├── delete_at.html │ ├── deprecated.html │ ├── dequeS3.html │ ├── dict.table.html │ ├── dictS3.html │ ├── dicttable.html │ ├── discard.Container.html │ ├── discard.html │ ├── discard_at.Container.html │ ├── discard_at.dict.table.html │ ├── discard_at.html │ ├── empty.Container.html │ ├── empty.html │ ├── figures │ │ ├── logo.png │ │ └── logo2.xcf │ ├── getContainerOption.html │ ├── get_label.html │ ├── get_next.html │ ├── get_value.html │ ├── has.Container.html │ ├── has.dict.table.html │ ├── has.html │ ├── has_name.Container.html │ ├── has_name.dict.table.html │ ├── has_name.html │ ├── has_next.html │ ├── has_value.html │ ├── index.html │ ├── is.container.html │ ├── is.deque.html │ ├── is.dict.html │ ├── is.dict.table.html │ ├── is.iterable.html │ ├── is.iterator.html │ ├── is.orderedset.html │ ├── is.set.html │ ├── is.subsettable.html │ ├── is_empty.Container.html │ ├── is_empty.dict.table.html │ ├── is_empty.html │ ├── iter.Container.html │ ├── iter.default.html │ ├── iter.html │ ├── iterS3.html │ ├── keys.html │ ├── length.Container.html │ ├── length.Iterator.html │ ├── names.Container.html │ ├── next_iter.html │ ├── peek.Deque.html │ ├── peek.html │ ├── peek_at.Container.html │ ├── peek_at.dict.table.html │ ├── peek_at.html │ ├── peek_at2.Container.html │ ├── peek_at2.dict.table.html │ ├── peek_at2.html │ ├── peekleft.Deque.html │ ├── peekleft.html │ ├── pop.html │ ├── pos.html │ ├── rbind.dict.table.html │ ├── ref_add.Container.html │ ├── ref_add.Dict.html │ ├── ref_add.dict.table.html │ ├── ref_add.html │ ├── ref_addleft.Deque.html │ ├── ref_addleft.html │ ├── ref_clear.Container.html │ ├── ref_clear.dict.table.html │ ├── ref_clear.html │ ├── ref_delete.Container.html │ ├── ref_delete.html │ ├── ref_delete_at.Container.html │ ├── ref_delete_at.dict.table.html │ ├── ref_delete_at.html │ ├── ref_discard.Container.html │ ├── ref_discard.html │ ├── ref_discard_at.Container.html │ ├── ref_discard_at.dict.table.html │ ├── ref_discard_at.html │ ├── ref_pop.Container.html │ ├── ref_pop.Deque.html │ ├── ref_pop.dict.table.html │ ├── ref_pop.html │ ├── ref_popleft.Deque.html │ ├── ref_popleft.html │ ├── ref_rename.dict.table.html │ ├── ref_rename.html │ ├── ref_replace.Container.html │ ├── ref_replace.Dict.html │ ├── ref_replace.html │ ├── ref_replace_at.Container.html │ ├── ref_replace_at.dict.table.html │ ├── ref_replace_at.html │ ├── ref_rev.Deque.html │ ├── ref_rev.html │ ├── ref_rotate.Deque.html │ ├── ref_rotate.html │ ├── ref_update.Container.html │ ├── ref_update.dict.table.html │ ├── ref_update.html │ ├── rename.Container.html │ ├── rename.default.html │ ├── rename.dict.table.html │ ├── rename.html │ ├── replace.Container.html │ ├── replace.Dict.html │ ├── replace.html │ ├── replace_at.Container.html │ ├── replace_at.dict.table.html │ ├── replace_at.html │ ├── reset_iter.html │ ├── rev.Deque.html │ ├── rev.html │ ├── rotate.Deque.html │ ├── rotate.html │ ├── setS3.html │ ├── setnew.html │ ├── size.Container.html │ ├── size.html │ ├── sortkey.Dict.html │ ├── sortkey.html │ ├── unpack.html │ ├── update.Container.html │ ├── update.dict.table.html │ ├── update.html │ ├── update.list.html │ ├── values.Container.html │ ├── values.dict.table.html │ └── values.html ├── search.json └── sitemap.xml ├── inst └── tinytest │ ├── test_0-ContainerR6.R │ ├── test_0-ContainerS3.R │ ├── test_0-DequeR6.R │ ├── test_0-DequeS3.R │ ├── test_0-DictR6.R │ ├── test_0-DictS3.R │ ├── test_0-IteratorR6.R │ ├── test_0-IteratorS3.R │ ├── test_0-SetR6.R │ ├── test_0-SetS3.R │ ├── test_0-dict.table.R │ ├── test_GroupGenericMath.R │ ├── test_GroupGenericSummary.R │ ├── test_Ops-arithmetic.R │ ├── test_Ops-compare.R │ ├── test_Ops-extract.R │ ├── test_Ops-logic.R │ ├── test_Ops-replace.R │ ├── test_add.R │ ├── test_addleft.R │ ├── test_all.equal.R │ ├── test_at.R │ ├── test_at2.R │ ├── test_clear.R │ ├── test_clone.R │ ├── test_container-deprecated.R │ ├── test_count.R │ ├── test_delete.R │ ├── test_delete_at.R │ ├── test_discard.R │ ├── test_discard_at.R │ ├── test_format.R │ ├── test_get_label.R │ ├── test_has.R │ ├── test_has_name.R │ ├── test_is_empty.R │ ├── test_options.R │ ├── test_peek.R │ ├── test_peek_at.R │ ├── test_peek_at2.R │ ├── test_pop.R │ ├── test_rename.R │ ├── test_replace.R │ ├── test_replace_at.R │ ├── test_rev.R │ ├── test_rotate.R │ ├── test_unpack.R │ ├── test_update.R │ ├── test_utils_index.R │ └── test_utils_misc.R ├── man ├── Container.Rd ├── ContainerS3.Rd ├── Deque.Rd ├── Dict.Rd ├── Iterable.Rd ├── Iterator.Rd ├── OpsArithmetic.Rd ├── OpsCompare.Rd ├── OpsExtract.Rd ├── OpsLogic.Rd ├── OpsReplace.Rd ├── OrderedSet.Rd ├── Set.Rd ├── add.Rd ├── addleft.Rd ├── at.Rd ├── at2.Rd ├── clear.Rd ├── clone.Rd ├── container_options.Rd ├── count.Rd ├── delete.Rd ├── delete_at.Rd ├── deprecated.Rd ├── dequeS3.Rd ├── dict.table.Rd ├── dictS3.Rd ├── discard.Rd ├── discard_at.Rd ├── figures │ └── logo.png ├── has.Rd ├── has_name.Rd ├── is_empty.Rd ├── iterS3.Rd ├── peek.Rd ├── peek_at.Rd ├── peek_at2.Rd ├── pop.Rd ├── rename.Rd ├── replace.Rd ├── replace_at.Rd ├── rev.Rd ├── rotate.Rd ├── setS3.Rd ├── unpack.Rd └── update.Rd ├── pkgdown └── favicon │ ├── apple-touch-icon-120x120.png │ ├── apple-touch-icon-152x152.png │ ├── apple-touch-icon-180x180.png │ ├── apple-touch-icon-60x60.png │ ├── apple-touch-icon-76x76.png │ ├── apple-touch-icon.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ └── favicon.ico ├── tests └── tinytest.R └── vignettes ├── v01-interactive-usage.Rmd ├── v02-code-development.Rmd ├── v03-parameter-list.Rmd ├── v04-manage-data-columns.Rmd ├── v05-deque-set-dict.Rmd └── v06-reference-semantics.Rmd /.Rbuildignore: -------------------------------------------------------------------------------- 1 | .git 2 | .gitignore 3 | TODO 4 | ^.*\.Rproj$ 5 | ^\.Rproj\.user$ 6 | ^\.github$ 7 | tags 8 | ^pkgdown$ 9 | ^_pkgdown\.yml$ 10 | ^docs$ 11 | ^doc$ 12 | ^README\.Rmd$ 13 | ^doc$ 14 | ^Meta$ 15 | 16 | ^images$ 17 | -------------------------------------------------------------------------------- /.github/.gitignore: -------------------------------------------------------------------------------- 1 | *.html 2 | -------------------------------------------------------------------------------- /.github/workflows/check-standard.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: [push] 4 | name: R-CMD-check 5 | 6 | jobs: 7 | R-CMD-check: 8 | runs-on: ${{ matrix.config.os }} 9 | 10 | name: ${{ matrix.config.os }} (${{ matrix.config.r }}) 11 | 12 | strategy: 13 | fail-fast: false 14 | matrix: 15 | config: 16 | - {os: macos-latest, r: 'release'} 17 | - {os: windows-latest, r: 'release'} 18 | - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} 19 | - {os: ubuntu-latest, r: 'release'} 20 | - {os: ubuntu-latest, r: 'oldrel-1'} 21 | 22 | env: 23 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 24 | R_KEEP_PKG_SOURCE: yes 25 | 26 | steps: 27 | - uses: actions/checkout@v3 28 | 29 | - uses: r-lib/actions/setup-pandoc@v2 30 | 31 | - uses: r-lib/actions/setup-r@v2 32 | with: 33 | r-version: ${{ matrix.config.r }} 34 | http-user-agent: ${{ matrix.config.http-user-agent }} 35 | use-public-rspm: true 36 | 37 | - uses: r-lib/actions/setup-r-dependencies@v2 38 | with: 39 | extra-packages: any::rcmdcheck 40 | needs: check 41 | 42 | - uses: r-lib/actions/check-r-package@v2 43 | with: 44 | upload-snapshots: true -------------------------------------------------------------------------------- /.github/workflows/test-coverage.yaml: -------------------------------------------------------------------------------- 1 | # Workflow derived from https://github.com/r-lib/actions/tree/v2/examples 2 | # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help 3 | on: [push] 4 | name: test-coverage 5 | 6 | jobs: 7 | test-coverage: 8 | runs-on: ubuntu-latest 9 | env: 10 | GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} 11 | 12 | steps: 13 | - uses: actions/checkout@v3 14 | 15 | - uses: r-lib/actions/setup-r@v2 16 | with: 17 | use-public-rspm: true 18 | 19 | - uses: r-lib/actions/setup-r-dependencies@v2 20 | with: 21 | extra-packages: any::covr 22 | needs: coverage 23 | 24 | - name: Test coverage 25 | run: | 26 | Sys.setenv(R_CODECOV_ENV = "GITHUB_ACTION") 27 | covr::codecov( 28 | quiet = FALSE, 29 | clean = FALSE, 30 | install_path = file.path( 31 | normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package") 32 | ) 33 | shell: Rscript {0} 34 | 35 | - name: Show testthat output 36 | if: always() 37 | run: | 38 | ## -------------------------------------------------------------------- 39 | find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true 40 | shell: bash 41 | 42 | - name: Upload test results 43 | if: failure() 44 | uses: actions/upload-artifact@v3 45 | with: 46 | name: coverage-test-failures 47 | path: ${{ runner.temp }}/package -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | 4 | container.Rproj 5 | 6 | vignettes/*.html 7 | tags 8 | 9 | check 10 | /doc/ 11 | /Meta/ 12 | 13 | vignettes/manage-data-columns_cache 14 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: container 2 | Type: Package 3 | Title: Extending Base 'R' Lists 4 | Version: 1.0.5 5 | Authors@R: 6 | person("Roman", "Pahl", 7 | email = "roman.pahl@gmail.com", role = c("aut", "cre")) 8 | Description: Extends the functionality of base 'R' lists and 9 | provides specialized data structures 'deque', 10 | 'set', 'dict', and 'dict.table', the latter to extend the 'data.table' 11 | package. 12 | Depends: R (>= 3.5.0) 13 | License: GPL-3 14 | Encoding: UTF-8 15 | Imports: data.table, methods, R6 16 | VignetteBuilder: knitr 17 | Suggests: 18 | knitr, 19 | tinytest, 20 | rmarkdown, 21 | microbenchmark, 22 | ggplot2, 23 | dplyr, 24 | tibble, 25 | testthat (>= 3.0.0) 26 | URL: https://rpahl.github.io/container/, https://github.com/rpahl/container 27 | BugReports: https://github.com/rpahl/container/issues 28 | NeedsCompilation: no 29 | Author: Roman Pahl [aut, cre] 30 | Maintainer: Roman Pahl 31 | Repository: CRAN 32 | RoxygenNote: 7.2.1 33 | Roxygen: list(markdown = TRUE) 34 | Config/testthat/edition: 3 35 | -------------------------------------------------------------------------------- /R/0-DequeS3.R: -------------------------------------------------------------------------------- 1 | #' Deque - Double-Ended Queue 2 | #' 3 | #' @description Deques are a generalization of stacks and queues typically 4 | #' with methods to add, remove and access elements at both sides of the 5 | #' underlying data sequence. As such, the [deque] can also be used to mimic 6 | #' both stacks and queues. 7 | #' @param ... initial elements put into the `Deque`. 8 | #' @param x `R` object of `ANY` type for [as.deque()] and [is.deque()] 9 | #' or of class `Deque` for the `S3` methods. 10 | #' @seealso See [container()] for all inherited methods. For the full class 11 | #' documentation see [Deque()] and it's superclass [Container()]. 12 | #' @name DequeS3 13 | #' @details 14 | #' Methods that alter [Deque] objects usually come in two versions 15 | #' providing either copy or reference semantics where the latter start with 16 | #' `'ref_'` to note the reference semantic, for example, `add()` and `ref_add()`. 17 | #' @examples 18 | #' d = deque(1, 2, s = "a", v = 1:3) 19 | #' is.deque(d) 20 | #' print(d) 21 | #' length(d) 22 | #' names(d) 23 | #' as.list(d) 24 | #' rev(d) 25 | #' 26 | #' l = list(0, 1) 27 | #' d2 = as.deque(l) 28 | #' d + d2 29 | #' c(d, d2) # same as d + d2 30 | #' d2 + d 31 | #' d - d2 32 | #' c(d2, d) # same as d2 + d 33 | #' d2 - d 34 | NULL 35 | 36 | #' @rdname DequeS3 37 | #' @details * `deque(...)` initializes and returns an object of class `Deque` 38 | #' @export 39 | deque <- function(...) Deque$new(...)$clone(deep = TRUE) 40 | 41 | #' @rdname DequeS3 42 | #' @details * `as.deque(x)` coerces `x` to a deque. 43 | #' @export 44 | as.deque <- function(x) do.call(deque, args = as.list(x)) 45 | 46 | methods::setOldClass("Deque") 47 | methods::setAs("list", "Deque", function(from) as.deque(from)) 48 | 49 | 50 | #' @rdname DequeS3 51 | #' @details * `is.deque(x)` returns `TRUE` if `x` is of class `Deque` 52 | #' and `FALSE` otherwise. 53 | #' @export 54 | is.deque <- function(x) inherits(x, "Deque") 55 | 56 | #' @export 57 | c.Deque <- function(..., recursive = FALSE, use.names = TRUE) 58 | { 59 | concat = c.Container(..., recursive = recursive, use.names = use.names) 60 | 61 | if (recursive) 62 | concat 63 | else 64 | as.deque(concat) 65 | } 66 | 67 | -------------------------------------------------------------------------------- /R/GroupGenericMath.R: -------------------------------------------------------------------------------- 1 | #' @name ContainerS3 2 | #' @rdname ContainerS3 3 | #' @examples 4 | #' # Math 5 | #' co = container(1, 2, -(3:5)) 6 | #' co 7 | #' abs(co) 8 | #' cumsum(co) 9 | #' round(co) 10 | #' exp(co) 11 | #' 12 | NULL 13 | 14 | #' @export 15 | Math.Container <- function(x, ...) 16 | { 17 | as.container(get(.Generic)(unpack(x), ...)) 18 | } 19 | 20 | #' @name DequeS3 21 | #' @rdname DequeS3 22 | #' @examples 23 | #' # Math 24 | #' d = deque(1, 2, -(3:5)) 25 | #' d 26 | #' abs(d) 27 | #' cumsum(d) 28 | #' round(d) 29 | #' exp(d) 30 | #' 31 | NULL 32 | 33 | #' @export 34 | Math.Deque <- function(x, ...) 35 | { 36 | as.deque(get(.Generic)(unpack(x), ...)) 37 | } 38 | 39 | #' @name DictS3 40 | #' @rdname DictS3 41 | #' @examples 42 | #' # Math 43 | #' d = dict(a = rnorm(1), b = rnorm(1)) 44 | #' abs(d) 45 | #' cumsum(d) 46 | #' round(d) 47 | #' exp(d) 48 | #' 49 | NULL 50 | 51 | #' @export 52 | Math.Dict <- function(x, ...) 53 | { 54 | as.dict(get(.Generic)(unpack(x), ...)) 55 | } 56 | 57 | #' @name SetS3 58 | #' @rdname SetS3 59 | #' @examples 60 | #' # Math 61 | #' s = setnew(5:3, 1, 2) 62 | #' s 63 | #' abs(s) 64 | #' cumsum(s) 65 | #' round(s) 66 | #' exp(s) 67 | #' 68 | NULL 69 | 70 | #' @export 71 | Math.Set <- function(x, ...) 72 | { 73 | as.set(get(.Generic)(unpack(x), ...)) 74 | } 75 | 76 | -------------------------------------------------------------------------------- /R/GroupGenericSummary.R: -------------------------------------------------------------------------------- 1 | #' @name ContainerS3 2 | #' @rdname ContainerS3 3 | #' @examples 4 | #' # Summary 5 | #' range(co) 6 | #' min(co) 7 | #' max(co) 8 | #' 9 | NULL 10 | 11 | #' @export 12 | Summary.Container <- function(..., na.rm = FALSE) 13 | { 14 | get(.Generic)(unlist(lapply(..., unpack)), na.rm = na.rm) 15 | } 16 | 17 | #' @name DequeS3 18 | #' @rdname DequeS3 19 | #' @examples 20 | #' # Summary 21 | #' range(d) 22 | #' min(d) 23 | #' max(d) 24 | #' 25 | NULL 26 | 27 | #' @export 28 | Summary.Deque <- function(..., na.rm = FALSE) 29 | { 30 | get(.Generic)(unlist(lapply(..., unpack)), na.rm = na.rm) 31 | } 32 | 33 | #' @name DictS3 34 | #' @rdname DictS3 35 | #' @examples 36 | #' # Summary 37 | #' range(d) 38 | #' min(d) 39 | #' max(d) 40 | #' 41 | NULL 42 | 43 | #' @export 44 | Summary.Dict <- function(..., na.rm = FALSE) 45 | { 46 | get(.Generic)(unlist(lapply(..., unpack)), na.rm = na.rm) 47 | } 48 | 49 | #' @name SetS3 50 | #' @rdname SetS3 51 | #' @examples 52 | #' # Summary 53 | #' range(s) 54 | #' min(s) 55 | #' max(s) 56 | #' 57 | NULL 58 | 59 | #' @export 60 | Summary.Set <- function(..., na.rm = FALSE) 61 | { 62 | get(.Generic)(unlist(lapply(..., unpack)), na.rm = na.rm) 63 | } 64 | 65 | -------------------------------------------------------------------------------- /R/Ops-extract.R: -------------------------------------------------------------------------------- 1 | #' Extract Parts of a Container Object 2 | #' 3 | #' @description Extract parts of a `Container` object similar 4 | #' to R's base extract operators on lists. 5 | #' @name OpsExtract 6 | #' @param x `Container` object from which to extract elements. 7 | #' @param i,... indices specifying elements to extract. Indices 8 | #' are `numeric` or `character` vectors or a `list` containing both. 9 | #' @details 10 | #' `[` selects multiple values. The indices can be `numeric` or 11 | #' `character` or both. They can be passed as a `vector` or `list` or, 12 | #' for convenience, just as a comma-separated sequence (see Examples). 13 | #' Non-existing indices are ignored. 14 | #' 15 | #' `[[` selects a single value using a `numeric` or `character` index. 16 | NULL 17 | 18 | #' @rdname OpsExtract 19 | #' @examples 20 | #' co = container(a = 1, b = 2, c = 3, d = 4) 21 | #' co[1:2] 22 | #' co[1, 4] 23 | #' co["d", 2] 24 | #' co[list("d", 2)] 25 | #' co[0:10] 26 | #' @export 27 | "[.Container" <- function(x, ...) 28 | { 29 | dots = tryCatch(list(...), error = identity) 30 | 31 | if (inherits(dots, "error")) 32 | return(x) 33 | 34 | if (all(sapply(dots, is.logical))) { 35 | v = rep(unlist(dots), length.out = length(x)) 36 | return(peek_at(x, which(v))) 37 | } 38 | 39 | peek_at(x, ...) 40 | } 41 | 42 | #' @name ContainerS3 43 | #' @rdname ContainerS3 44 | #' @examples 45 | #' # Extract or replace 46 | #' co = container(a = 1, b = 2, c = 3, d = 4) 47 | #' co[1:2] 48 | #' co[1, 4] 49 | #' co["d", 2] 50 | #' co[list("d", 2)] 51 | #' co[0:10] 52 | NULL 53 | 54 | 55 | #' @rdname OpsExtract 56 | #' @examples 57 | #' 58 | #' co = container(a = 1, b = 2) 59 | #' co[[1]] 60 | #' co[["a"]] 61 | #' co[["x"]] 62 | #' @export 63 | "[[.Container" <- function(x, i) 64 | { 65 | x$peek_at2(i) 66 | } 67 | 68 | #' @name ContainerS3 69 | #' @rdname ContainerS3 70 | #' @examples 71 | #' 72 | #' co = container(a = 1, b = 2) 73 | #' co[[1]] 74 | #' co[["a"]] 75 | #' co[["x"]] 76 | NULL 77 | 78 | 79 | -------------------------------------------------------------------------------- /R/addleft.R: -------------------------------------------------------------------------------- 1 | #' Add Elements to the Left of Deques 2 | #' 3 | #' Add elements to left side of [Deque] objects. 4 | #' @param .x a `[Deque]` object 5 | #' @param ... elements to be added. 6 | #' @note While [addleft] uses copy semantics [ref_addleft] work by reference. 7 | #' @export 8 | addleft <- function(.x, ...) UseMethod("addleft") 9 | 10 | #' @rdname addleft 11 | #' @export 12 | ref_addleft <- function(.x, ...) UseMethod("ref_addleft") 13 | 14 | 15 | #' @rdname addleft 16 | #' @return For [Deque], an object of class [Deque] with the elements being 17 | #' added to the left of `.x`. 18 | #' @export 19 | #' @examples 20 | #' d = deque(0) 21 | #' add(d, a = 1, b = 2) # |0, a = 1, b = 2| 22 | #' addleft(d, a = 1, b = 2) # |b = 2, a = 1, 0| 23 | addleft.Deque <- function(.x, ...) 24 | { 25 | (ref_addleft(.x$clone(deep = TRUE), ...)) 26 | } 27 | 28 | #' @name DequeS3 29 | #' @rdname DequeS3 30 | #' @details 31 | #' * `addleft(.x, ...)` adds (possibly named) elements to left side of `.x`. 32 | #' * `ref_addleft(.x, ...)` same as `addleft(.x, ...)` but adds by reference. 33 | #' @examples 34 | #' 35 | #' d = deque(0) 36 | #' add(d, a = 1, b = 2) # |0, a = 1, b = 2| 37 | #' addleft(d, a = 1, b = 2) # |b = 2, a = 1, 0| 38 | NULL 39 | 40 | #' @rdname addleft 41 | #' @export 42 | ref_addleft.Deque <- function(.x, ...) 43 | { 44 | elems = list(...) 45 | elem_names = names(elems) 46 | 47 | for (i in seq_along(elems)) 48 | .x$addleft(elems[[i]], name = elem_names[[i]]) 49 | 50 | invisible(.x) 51 | } 52 | 53 | 54 | -------------------------------------------------------------------------------- /R/all.equal.R: -------------------------------------------------------------------------------- 1 | .has_equal_containers = function(x, y, ...) 2 | { 3 | if (!identical(data.class(x), data.class(y))) 4 | return(FALSE) 5 | 6 | if (length(x) != length(y)) 7 | return(FALSE) 8 | 9 | 10 | if (!identical(names(x), names(y))) 11 | return(FALSE) 12 | 13 | x.iter = x$iter() 14 | y.iter = y$iter() 15 | 16 | is_equal = match.fun(container_options("compare")[[1]]) 17 | 18 | while (x.iter$has_next()) { 19 | target = x.iter$get_next()[[1]] 20 | current = y.iter$get_next()[[1]] 21 | if (!isTRUE(is_equal(target, current, ...))) 22 | return(FALSE) 23 | } 24 | 25 | TRUE 26 | } 27 | 28 | 29 | #' @export 30 | all.equal.Container = function(target, current, ...) 31 | { 32 | if (.has_equal_containers(target, current)) 33 | return(TRUE) 34 | 35 | # TODO: construct messages for non-equality case 36 | FALSE 37 | } 38 | 39 | -------------------------------------------------------------------------------- /R/clear.R: -------------------------------------------------------------------------------- 1 | #' Clear a Container 2 | #' 3 | #' Removes all elements from the container object. 4 | #' @param x any `R` object. 5 | #' @export 6 | clear <- function(x) UseMethod("clear") 7 | 8 | #' @rdname clear 9 | #' @export 10 | ref_clear <- function(x) UseMethod("ref_clear") 11 | 12 | 13 | #' @rdname clear 14 | #' @return For [Container], an object of class [Container] (or one of the 15 | #' respective derived classes). 16 | #' @export 17 | #' @examples 18 | #' 19 | #' co = container(1, 2, mean) 20 | #' clear(co) 21 | #' co 22 | #' ref_clear(co) 23 | #' co 24 | clear.Container <- function(x) (x$clone(deep = TRUE)$clear()) 25 | 26 | #' @name ContainerS3 27 | #' @rdname ContainerS3 28 | #' @details 29 | #' * `clear(x)` and `ref_clear(x)` remove all elements from `x`. 30 | #' @examples 31 | #' 32 | #' co = container(1, 2, mean) 33 | #' clear(co) 34 | #' print(co) # Original was not touched 35 | #' ref_clear(co) # Clears original 36 | #' print(co) 37 | NULL 38 | 39 | #' @rdname clear 40 | #' @export 41 | ref_clear.Container <- function(x) 42 | { 43 | invisible(x$clear()) 44 | } 45 | 46 | 47 | #' @rdname clear 48 | #' @return For [dict.table] an object of class 49 | #' [dict.table]. 50 | #' @export 51 | #' @examples 52 | #' 53 | #' dit = dict.table(a = 1, b = 2) 54 | #' clear(dit) 55 | #' dit # original was not touched 56 | #' ref_clear(dit) 57 | #' dit # original was cleared 58 | clear.dict.table <- function(x) dict.table() 59 | 60 | #' @name dict.table 61 | #' @rdname dict.table 62 | #' @details 63 | #' * `clear(x)` and `ref_clear(x)` remove all elements from `x`. 64 | #' @examples 65 | #' 66 | #' dit = dict.table(a = 1, b = 2) 67 | #' clear(dit) 68 | #' dit 69 | #' ref_clear(dit) 70 | #' dit 71 | NULL 72 | 73 | #' @rdname clear 74 | #' @export 75 | ref_clear.dict.table <- function(x) 76 | { 77 | data.table::set(x, j = seq_len(ncol(x)), value = NULL) 78 | 79 | invisible(x) 80 | } 81 | 82 | -------------------------------------------------------------------------------- /R/clone.R: -------------------------------------------------------------------------------- 1 | #' Clone an Object 2 | #' 3 | #' Creates a copy of the object. 4 | #' @param x any `R` object. 5 | #' @return A copy of the object. 6 | #' @export 7 | clone <- function(x) UseMethod("clone") 8 | 9 | 10 | #' @rdname clone 11 | #' @export 12 | #' @examples 13 | #' 14 | #' co = container(1, 2, 3) 15 | #' co2 = clone(co) 16 | #' co == co2 17 | clone.Container <- function(x) (x$clone(deep = TRUE)) 18 | 19 | #' @name ContainerS3 20 | #' @rdname ContainerS3 21 | #' @details 22 | #' * `clone(x)` create a copy of `x`. 23 | #' @examples 24 | #' 25 | #' co = container(1, 2, 3) 26 | #' co2 = clone(co) 27 | #' co == co2 28 | NULL 29 | 30 | 31 | #' @rdname clone 32 | #' @export 33 | #' @examples 34 | #' 35 | #' d = dict.table(a = 1:2, b = 3:4) 36 | #' d2 = clone(d) 37 | #' ref_clear(d) 38 | #' print(d2) 39 | clone.dict.table <- function(x) (copy(x)) 40 | 41 | #' @name dict.table 42 | #' @rdname dict.table 43 | #' @details 44 | #' * `clone(x)` create a copy of `x`. 45 | #' @examples 46 | #' 47 | #' d = dict.table(a = 1:2, b = 3:4) 48 | #' d2 = clone(d) 49 | #' ref_clear(d) 50 | #' print(d2) 51 | NULL 52 | 53 | -------------------------------------------------------------------------------- /R/container-deprecated.R: -------------------------------------------------------------------------------- 1 | #' Deprecated Functions 2 | #' 3 | #' @description These functions are provided for backwards-compatibility and 4 | #' may be defunct as soon as the next release. 5 | #' @param x any `R` object. 6 | #' @details 7 | #' * [empty()] [is_empty()] instead 8 | #' * `set` [setnew()] instead 9 | #' * [size()] use [length()] instead 10 | #' * [sortkey()] keys of [Dict] objects are now always sorted 11 | #' * [remove()] use [delete()] instead 12 | #' * [type()] not of use anymore 13 | #' * [values()] use [as.list()] instead 14 | #' @name deprecated 15 | NULL 16 | 17 | #' @rdname deprecated 18 | #' @export 19 | empty <- function(x) UseMethod("empty") 20 | 21 | #' @rdname deprecated 22 | #' @export 23 | empty.Container <- function(x) 24 | { 25 | .Deprecated("is_empty") 26 | is_empty(x) 27 | } 28 | 29 | 30 | #' @rdname deprecated 31 | #' @export 32 | size <- function(x) UseMethod("size") 33 | 34 | #' @rdname deprecated 35 | #' @export 36 | size.Container <- function(x) 37 | { 38 | .Deprecated("length") 39 | length(x) 40 | } 41 | 42 | #' @rdname deprecated 43 | #' @param decr `logical` sort decreasingly? 44 | #' @export 45 | sortkey <- function(x, decr = FALSE) UseMethod("sortkey") 46 | 47 | #' @rdname deprecated 48 | #' @export 49 | sortkey.Dict <- function(x, decr = FALSE) { 50 | .Deprecated(msg = "'sort' is deprecated - keys are now always sorted") 51 | invisible(x) 52 | } 53 | 54 | 55 | #' @rdname deprecated 56 | #' @export 57 | values <- function(x) 58 | UseMethod("values") 59 | 60 | #' @rdname deprecated 61 | #' @export 62 | values.Container <- function(x) 63 | { 64 | .Deprecated("as.list") 65 | as.list(x) 66 | } 67 | 68 | #' @rdname deprecated 69 | #' @export 70 | values.dict.table <- function(x) 71 | { 72 | .Deprecated("as.list") 73 | as.list(x) 74 | } 75 | 76 | 77 | #' @rdname deprecated 78 | #' @export 79 | keys <- function(x) 80 | { 81 | .Deprecated("names") 82 | names(x) 83 | } 84 | 85 | 86 | set <- function(...) { 87 | .Deprecated("setnew") 88 | setnew(...) 89 | } 90 | 91 | 92 | -------------------------------------------------------------------------------- /R/container-pkg.R: -------------------------------------------------------------------------------- 1 | .onLoad <- function(libname, pkgname) 2 | { 3 | invisible() 4 | } 5 | 6 | -------------------------------------------------------------------------------- /R/count.R: -------------------------------------------------------------------------------- 1 | #' Count Elements 2 | #' 3 | #' @description Count the number of occurences of some element. 4 | #' @param x any `R` object. 5 | #' @param elem element to counted. 6 | #' @return `integer` number of how many times `elem` occurs in the object. 7 | #' @export 8 | count <- function(x, elem) UseMethod("count") 9 | 10 | #' @rdname count 11 | #' @export 12 | #' @examples 13 | #' 14 | #' co = container("a", "b", "a", mean, mean) 15 | #' count(co, "a") 16 | #' count(co, mean) 17 | #' count(co, "c") 18 | count.Container <- function(x, elem) { 19 | x$count(elem) 20 | } 21 | 22 | 23 | #' @name ContainerS3 24 | #' @rdname ContainerS3 25 | #' @details 26 | #' * `count(x, elem)` count how often `elem` occurs in `x`. 27 | #' @examples 28 | #' 29 | #' co = container("a", "b", "a", mean, mean) 30 | #' count(co, "a") 31 | #' count(co, mean) 32 | #' count(co, "c") 33 | NULL 34 | 35 | 36 | #' @rdname count 37 | #' @export 38 | count.Set <- function(x, elem) as.integer(x$has(elem)) 39 | 40 | 41 | -------------------------------------------------------------------------------- /R/delete.R: -------------------------------------------------------------------------------- 1 | #' Delete Container Elements Safely 2 | #' 3 | #' Search and remove elements from an object. If the element is not found, 4 | #' an error is signaled. 5 | #' @param .x any `R` object. 6 | #' @param ... elements to be deleted. 7 | #' @export 8 | delete <- function(.x, ...) UseMethod("delete") 9 | 10 | #' @rdname delete 11 | #' @export 12 | ref_delete <- function(.x, ...) UseMethod("ref_delete") 13 | 14 | 15 | #' @rdname delete 16 | #' @return For `Container`, an object of class `Container` (or one of the 17 | #' respective derived classes). 18 | #' @examples 19 | #' 20 | #' s = setnew("a", 1:3, iris) 21 | #' print(s) 22 | #' delete(s, 1:3, "a") 23 | #' delete(s, iris) 24 | #' try({ 25 | #' delete(s, "b") # "b" is not in Set 26 | #' }) 27 | #' @export 28 | delete.Container <- function(.x, ...) 29 | { 30 | (ref_delete(.x$clone(deep = TRUE), ...)) 31 | } 32 | 33 | #' @name ContainerS3 34 | #' @rdname ContainerS3 35 | #' @details 36 | #' * `delete(.x, ...)` and `ref_delete(.x, ...)` find and remove elements. 37 | #' If one or more elements don't exist, an error is signaled. 38 | #' @examples 39 | #' 40 | #' co = container("a", 1:3, iris) 41 | #' print(co) 42 | #' delete(co, 1:3, "a") 43 | #' delete(co, iris) 44 | #' try({ 45 | #' delete(co, "b") # "b" is not in Container 46 | #' }) 47 | NULL 48 | 49 | #' @rdname delete 50 | #' @export 51 | ref_delete.Container <- function(.x, ...) 52 | { 53 | elems = list(...) 54 | if (!length(elems)) 55 | return(.x) 56 | 57 | hasElements = sapply(elems, function(e) .x$has(e)) 58 | 59 | if (any(!hasElements)) { 60 | # Throw error by trying to delete first missing element 61 | element = elems[!hasElements][[1]] 62 | .x$delete(element) 63 | } 64 | 65 | lapply(elems, function(e) .x$delete(e)) 66 | invisible(.x) 67 | } 68 | 69 | 70 | -------------------------------------------------------------------------------- /R/discard.R: -------------------------------------------------------------------------------- 1 | #' Discard Container Elements 2 | #' 3 | #' Search and remove an element from an object. If the element is not found, 4 | #' ignore the attempt. 5 | #' @param .x any `R` object. 6 | #' @param ... elements to be discarded. 7 | #' @export 8 | discard <- function(.x, ...) UseMethod("discard") 9 | 10 | #' @rdname discard 11 | #' @export 12 | ref_discard <- function(.x, ...) UseMethod("ref_discard") 13 | 14 | 15 | #' @rdname discard 16 | #' @return For `Container`, an object of class `Container` (or one of the 17 | #' respective derived classes). 18 | #' @examples 19 | #' 20 | #' s = setnew("a", num = 1:3, data = iris) 21 | #' print(s) 22 | #' discard(s, 1:3, "a") 23 | #' discard(s, iris) 24 | #' discard(s, "b") # ignored 25 | #' @export 26 | discard.Container <- function(.x, ...) { 27 | (ref_discard(.x$clone(deep = TRUE), ...)) 28 | } 29 | 30 | #' @name ContainerS3 31 | #' @rdname ContainerS3 32 | #' @details 33 | #' * `discard(.x, ...)` and `ref_discard(.x, ...)` find and discard elements. 34 | #' Elements that don't exist, are ignored. 35 | #' @examples 36 | #' 37 | #' co = container("a", num = 1:3, data = iris) 38 | #' print(co) 39 | #' discard(co, 1:3, "a") 40 | #' discard(co, iris) 41 | #' discard(co, "b") # ignored 42 | NULL 43 | 44 | #' @rdname discard 45 | #' @export 46 | ref_discard.Container <- function(.x, ...) 47 | { 48 | elems = list(...) 49 | if (!length(elems)) 50 | return(.x) 51 | 52 | lapply(elems, function(e) .x$discard(e)) 53 | 54 | invisible(.x) 55 | } 56 | 57 | -------------------------------------------------------------------------------- /R/format.R: -------------------------------------------------------------------------------- 1 | .format_values <- 2 | function(x, left = "(", right = ")", ...) 3 | { 4 | x.names <- names(x) 5 | name_seps <- rep.int("", length(x)) 6 | 7 | if (!is.null(x.names)) 8 | name_seps[x.names != ""] <- " = " 9 | 10 | labels = sapply(x, .get_label, ...) 11 | 12 | obj_str = paste(x.names, name_seps, labels, sep = "", collapse = ", ") 13 | paste0(left, obj_str, right) 14 | } 15 | 16 | 17 | format.Container <- 18 | function(x, ...) { 19 | .format_values(x$values(), left = "[", right = "]", ...) 20 | } 21 | 22 | format.Deque <- 23 | function(x, ...) { 24 | .format_values(x$values(), left = "|", right = "|", ...) 25 | } 26 | 27 | format.Dict <- 28 | function(x, ...) { 29 | .format_values(x$values(), left = "{", right = "}", ...) 30 | } 31 | 32 | format.Set <- 33 | function(x, ...) { 34 | .format_values(x$values(), left = "{", right = "}", ...) 35 | } 36 | 37 | format.OrderedSet <- 38 | function(x, ...) { 39 | .format_values(x$values(), left = "{", right = "}", ...) 40 | } 41 | 42 | 43 | format.list <- 44 | function(x, ...) { 45 | .format_values(x, left = "list(", right = ")", ...) 46 | } 47 | 48 | -------------------------------------------------------------------------------- /R/get_label.R: -------------------------------------------------------------------------------- 1 | # Credits for the basic code idea belong to the authors of the `sets` package. 2 | 3 | .get_label.default = function(x, ...) 4 | { 5 | if (is.null(x)) 6 | return("NULL") 7 | 8 | s = class(x)[1L] 9 | 10 | if (!is.null(dim(x))) 11 | s = paste0(s, "(", paste(dim(x), collapse = "x"), ")") 12 | 13 | paste0("<<", s, ">>") 14 | } 15 | 16 | 17 | .get_atomic_label = function(x, vec.len = 4L, useDots = TRUE, ...) 18 | { 19 | s = .format_or_class_label(x, vec.len = ifelse(useDots, Inf, vec.len), ...) 20 | s = trimws(s) 21 | 22 | if (length(s) <= 1) 23 | return(s) 24 | 25 | if (length(s) > vec.len) 26 | s = s[1:vec.len] 27 | 28 | dots_or_empty = if(useDots && length(x) > vec.len) " ..." else "" 29 | 30 | paste0("(", paste(s, collapse = " "), dots_or_empty, ")") 31 | } 32 | 33 | 34 | .get_label.logical = function(x, vec.len = 4L, ...) 35 | .get_atomic_label(x, vec.len = max(1L, vec.len / 2), ...) 36 | 37 | 38 | .get_label.character = function(x, ...) 39 | { 40 | if (length(x)) 41 | x <- ifelse(is.na(x), x, paste0("\"", x, "\"")) 42 | 43 | .get_atomic_label(x, ...) 44 | } 45 | 46 | 47 | .format_or_class_label = function(x, vec.len = 4L, markInteger = TRUE, ...) 48 | { 49 | len <- length(x) 50 | if (len == 0) 51 | return(paste0(class(x)[1L], "()")) 52 | 53 | doCreateClassLabel = len > vec.len 54 | if (doCreateClassLabel) 55 | return(paste0("<<", class(x)[1L], "(", len, ")>>")) 56 | 57 | if (is.integer(x) && markInteger) 58 | format(ifelse(is.na(x), x, paste0(x, "L")), ...) 59 | else 60 | format(x, ...) 61 | } 62 | 63 | 64 | setGeneric(".get_label", .get_label.default) 65 | 66 | for (type in c("numeric", "factor", "integer")) 67 | setMethod(".get_label", signature(type), .get_atomic_label) 68 | 69 | for (type in c("list", "Container", "Deque", "Dict", "Set")) 70 | setMethod(".get_label", signature(type), .format_or_class_label) 71 | 72 | for (type in c("matrix", "data.frame")) 73 | setMethod(".get_label", signature(type), .get_label.default) 74 | 75 | 76 | setMethod(".get_label", signature("logical"), .get_label.logical) 77 | setMethod(".get_label", signature("character"), .get_label.character) 78 | 79 | -------------------------------------------------------------------------------- /R/has.R: -------------------------------------------------------------------------------- 1 | #' Check for Element 2 | #' 3 | #' @param x any `R` object. 4 | #' @param ... additional arguments to be passed to or from methods. 5 | #' @seealso [has_name()] 6 | #' @export 7 | has <- function(x, ...) UseMethod("has") 8 | 9 | 10 | #' @rdname has 11 | #' @param elem some element to be found. 12 | #' @return `TRUE` if element is in `x` and otherwise `FALSE`. 13 | #' @export 14 | #' @examples 15 | #' 16 | #' co = container(1, 2, mean) 17 | #' has(co, 1) # TRUE 18 | #' has(co, mean) # TRUE 19 | #' has(co, 1:2) # FALSE 20 | has.Container <- function(x, elem, ...) x$has(elem) 21 | 22 | #' @name ContainerS3 23 | #' @rdname ContainerS3 24 | #' @details 25 | #' * `has(x, elem)` `TRUE` if element is in `x` and otherwise `FALSE`. 26 | #' @examples 27 | #' 28 | #' co = container(1, 2, mean) 29 | #' has(co, 1) # TRUE 30 | #' has(co, mean) # TRUE 31 | #' has(co, 1:2) # FALSE 32 | NULL 33 | 34 | 35 | #' @rdname has 36 | #' @param column vector of values with the same length as the number of rows 37 | #' of the `dict.table`. 38 | #' @return For `dict.table`, `TRUE` if column exists in `x` otherwise `FALSE`. 39 | #' @export 40 | #' @examples 41 | #' 42 | #' dit = dict.table(a = 1:3, b = as.list(4:6)) 43 | #' has(dit, 1:3) # TRUE 44 | #' has(dit, 4:6) # FALSE 45 | #' has(dit, as.list(4:6)) # TRUE 46 | has.dict.table <- function(x, column, ...) 47 | { 48 | if (!length(x)) 49 | return(FALSE) 50 | 51 | if (length(column) != nrow(x)) { 52 | warning("length of column vector (", length(column), ") ", 53 | "does not match number of rows (", nrow(x), ")", call. = FALSE) 54 | return(FALSE) 55 | } 56 | 57 | has(as.container(x), column) 58 | } 59 | 60 | 61 | #' @name dict.table 62 | #' @rdname dict.table 63 | #' @details 64 | #' * `has(x, column)` check if some `column` is in dict.table object. 65 | #' @examples 66 | #' 67 | #' dit = dict.table(a = 1:3, b = as.list(4:6)) 68 | #' has(dit, 1:3) # TRUE 69 | #' has(dit, 4:6) # FALSE 70 | #' has(dit, as.list(4:6)) # TRUE 71 | NULL 72 | 73 | -------------------------------------------------------------------------------- /R/has_name.R: -------------------------------------------------------------------------------- 1 | #' Check for Name 2 | #' 3 | #' @param x any `R` object. 4 | #' @param name `character` the name to be found. 5 | #' @seealso [has()] 6 | #' @export 7 | has_name <- function(x, name) UseMethod("has_name") 8 | 9 | 10 | #' @rdname has_name 11 | #' @return `TRUE` if name is in `x` and otherwise `FALSE`. 12 | #' @export 13 | #' @examples 14 | #' 15 | #' co = container(a = 1, 2, f = mean) 16 | #' has_name(co, "a") # TRUE 17 | #' has_name(co, "f") # TRUE 18 | #' has_name(co, "2") # FALSE 19 | has_name.Container <- function(x, name) 20 | { 21 | if (missing(name)) 22 | return(isTRUE(length(names(x)) > 0)) 23 | 24 | x$has_name(name) 25 | } 26 | 27 | 28 | #' @name ContainerS3 29 | #' @rdname ContainerS3 30 | #' @details 31 | #' * `has_name(x, name)` check if `name` is in `x` 32 | #' @examples 33 | #' 34 | #' co = container(a = 1, 2, f = mean) 35 | #' has_name(co, "a") # TRUE 36 | #' has_name(co, "f") # TRUE 37 | #' has_name(co, "2") # FALSE 38 | NULL 39 | 40 | 41 | #' @rdname has_name 42 | #' @return For `dict.table` `TRUE` if the dict.table objects has the given 43 | #' column name, otherwise `FALSE`. 44 | #' @export 45 | #' @examples 46 | #' 47 | #' dit = dict.table(a = 1:2, b = 3:4) 48 | #' has_name(dit, "a") # TRUE 49 | #' has_name(dit, "x") # FALSE 50 | has_name.dict.table <- function(x, name) 51 | { 52 | if (missing(name)) 53 | return(isTRUE(length(names(x)) > 0)) 54 | 55 | if (!is.character(name)) 56 | stop("name must be a character string, but got '", 57 | data.class(name), "'", call. = FALSE) 58 | 59 | if (length(name) != 1) 60 | stop("name must be of length 1", call. = FALSE) 61 | 62 | if (is.na(name)) 63 | stop("undefined name", call. = FALSE) 64 | 65 | if (isTRUE(nchar(name) == 0)) 66 | stop("name must consist of at least one character", call. = F) 67 | 68 | isTRUE(utils::hasName(x, name)) 69 | } 70 | 71 | 72 | #' @name dict.table 73 | #' @rdname dict.table 74 | #' @details 75 | #' * `has_name(x, name)` check if `x` has the given column name. 76 | #' @examples 77 | #' 78 | #' dit = dict.table(a = 1, b = 2) 79 | #' has_name(dit, "a") # TRUE 80 | #' has_name(dit, "x") # FALSE 81 | NULL 82 | 83 | -------------------------------------------------------------------------------- /R/is_empty.R: -------------------------------------------------------------------------------- 1 | #' Check if Object is Empty 2 | #' 3 | #' @param x any `R` object. 4 | #' @return `TRUE` if object is empty otherwise `FALSE`. 5 | #' @export 6 | is_empty <- function(x) UseMethod("is_empty") 7 | 8 | #' @rdname is_empty 9 | #' @export 10 | #' @examples 11 | #' 12 | #' co = container(1, 2) 13 | #' is_empty(co) 14 | #' is_empty(clear(co)) 15 | is_empty.Container <- function(x) x$is_empty() 16 | 17 | 18 | #' @name ContainerS3 19 | #' @rdname ContainerS3 20 | #' @details 21 | #' * `is_empty(x)` `TRUE` if object is empty otherwise `FALSE` 22 | #' @examples 23 | #' 24 | #' co = container(1, 2) 25 | #' is_empty(co) 26 | #' is_empty(clear(co)) 27 | NULL 28 | 29 | 30 | #' @rdname is_empty 31 | #' @export 32 | #' @examples 33 | #' 34 | #' d = dict.table(a = 1:4, b = 4:1) 35 | #' is_empty(d) 36 | #' is_empty(clear(d)) 37 | is_empty.dict.table <- function(x) ncol(x) == 0 38 | 39 | 40 | #' @name dict.table 41 | #' @rdname dict.table 42 | #' @details 43 | #' * `is_empty(x)` `TRUE` if object is empty otherwise `FALSE` 44 | #' @examples 45 | #' 46 | #' d = dict.table(a = 1:4, b = 4:1) 47 | #' is_empty(d) 48 | #' is_empty(clear(d)) 49 | NULL 50 | -------------------------------------------------------------------------------- /R/peek.R: -------------------------------------------------------------------------------- 1 | #' Peek at Left or Right of a Deque 2 | #' 3 | #' Try to access first or last element and return some default value if not found. 4 | #' In contrast to `[at2()]`, this function provides a less stricter element 5 | #' access, that is, it remains valid even if peeked elements don't exist. 6 | #' @details 7 | #' `peek` peek at last element of a `Deque`. 8 | #' 9 | #' `peekleft` peek at first element of a `Deque`. 10 | #' @param x a `Deque` object. 11 | #' @param default value to be returned if peeked value does not exist. 12 | #' @return The first (`peekleft`) or last (`peek`) element. 13 | #' @seealso [at2()] for strict element extraction 14 | #' @name peek 15 | #' @export 16 | peekleft <- function(x, default = NULL) UseMethod("peekleft") 17 | 18 | #' @rdname peek 19 | #' @export 20 | peek <- function(x, default = NULL) UseMethod("peek") 21 | 22 | 23 | #' @rdname peek 24 | #' @export 25 | #' @examples 26 | #' # Deque 27 | #' d = deque(1, 2, 3) 28 | #' peek(d) 29 | #' peekleft(d) 30 | #' peek(deque()) 31 | #' peek(deque(), default = 0) 32 | #' peekleft(deque(), default = 0) 33 | peek.Deque <- function(x, default = NULL) x$peek(default) 34 | 35 | #' @rdname peek 36 | #' @export 37 | peekleft.Deque <- function(x, default = NULL) x$peekleft(default) 38 | 39 | 40 | #' @name DequeS3 41 | #' @rdname DequeS3 42 | #' @details 43 | #' * `peek(x, default = NULL)` peek at last element. If `x` is empty, return 44 | #' `default`. 45 | #' * `peekleft(x, default = NULL)` peek at first element. If `x` is empty, 46 | #' return `default`. 47 | #' @examples 48 | #' 49 | #' d = deque(1, 2, 3) 50 | #' peek(d) 51 | #' peekleft(d) 52 | #' peek(deque()) 53 | #' peek(deque(), default = 0) 54 | #' peekleft(deque(), default = 0) 55 | NULL 56 | 57 | -------------------------------------------------------------------------------- /R/rev.R: -------------------------------------------------------------------------------- 1 | #' Reverse Elements 2 | #' 3 | #' @description `rev` provides a reversed version of its argument. 4 | #' @param x `Deque` object 5 | #' @details `rev` uses copy semantics while `ref_rev` works by reference, 6 | #' that is, it reverse all elements in place. 7 | #' @seealso [base::rev()] 8 | #' @name rev 9 | NULL 10 | 11 | #' @rdname rev 12 | #' @export 13 | ref_rev <- function(x) UseMethod("ref_rev") 14 | 15 | #' @rdname rev 16 | #' @export 17 | ref_rev.Deque <- function(x) x$rev() 18 | 19 | 20 | #' @rdname rev 21 | #' @return For `Deque`, an object of class `Deque` 22 | #' @examples 23 | #' 24 | #' d = deque(a = 1, b = 2, 3) 25 | #' rev(d) 26 | #' print(d) 27 | #' ref_rev(d) 28 | #' print(d) 29 | #' 30 | #' @export 31 | rev.Deque <- function(x) x$clone(deep = TRUE)$rev() 32 | 33 | 34 | #' @name DequeS3 35 | #' @rdname DequeS3 36 | #' @details 37 | #' * `rev(x)` and `ref_rev(x)` reverses all elements being done on a copy or in 38 | #' place, respectively. 39 | #' @examples 40 | #' 41 | #' d = deque(a = 1, b = 2, 3) 42 | #' rev(d) 43 | #' print(d) 44 | #' ref_rev(d) 45 | #' print(d) 46 | NULL 47 | -------------------------------------------------------------------------------- /R/rotate.R: -------------------------------------------------------------------------------- 1 | #' Rotate Elements 2 | #' 3 | #' @description Rotate all elements `n` steps to the right. If n is 4 | #' negative, rotate to the left. 5 | #' @param x any `R` object. 6 | #' @param n `integer` number of steps to rotate 7 | #' @details While `rotate` uses copy semantics, `ref_rotate` works by reference, 8 | #' that is, rotates in place on the original object. 9 | #' @export 10 | rotate <- function(x, n = 1L) UseMethod("rotate") 11 | 12 | #' @rdname rotate 13 | #' @export 14 | ref_rotate <- function(x, n = 1L) UseMethod("ref_rotate") 15 | 16 | 17 | #' @rdname rotate 18 | #' @return For `Deque` returns the rotated [Deque()] object. 19 | #' @export 20 | #' @examples 21 | #' d = deque(1, 2, 3, 4) 22 | #' rotate(d) 23 | #' rotate(d, n = 2) 24 | rotate.Deque <- function(x, n = 1L) 25 | { 26 | (ref_rotate(x$clone(deep = TRUE), n)) 27 | } 28 | 29 | #' @name DequeS3 30 | #' @rdname DequeS3 31 | #' @details 32 | #' * `rotate(x, n)` rotate all elements `n` steps to the right, If `n` is 33 | #' negative, rotate to the left. 34 | #' @examples 35 | #' 36 | #' d = deque(1, 2, 3, 4) 37 | #' rotate(d) 38 | #' rotate(d, n = 2) 39 | #' 40 | NULL 41 | 42 | #' @rdname rotate 43 | #' @export 44 | ref_rotate.Deque <- function(x, n = 1L) 45 | { 46 | invisible(x$rotate(n)) 47 | } 48 | 49 | -------------------------------------------------------------------------------- /R/unpack.R: -------------------------------------------------------------------------------- 1 | #' Unpack Nested Objects 2 | #' 3 | #' Similary to [unlist()] recursively unpacks any (possibly nested) structure 4 | #' into a flat list. In contrast to [unlist()], [unpack()] also works with 5 | #' (possibly nested) [Container()] objects. In principle, it works for any 6 | #' object that can be transformed to a list via `as.list`. 7 | #' @param x any `R` object 8 | #' @param recursive `logical` descend recursively into nested objects? 9 | #' @param use.names `logical` Should names be preserved? 10 | #' @return a `list` 11 | #' @export 12 | unpack = function(x, recursive = TRUE, use.names = TRUE) { 13 | 14 | if (!is.recursive(x)) 15 | return(x) 16 | 17 | unpack_recursive = function(x) { 18 | if (is.container(x)) 19 | rapply(as.list(x), f = unpack_recursive) 20 | else 21 | unlist(x, recursive = TRUE, use.names = use.names) 22 | } 23 | 24 | unpack_nonrecursive = function(x) { 25 | if (is.container(x)) 26 | unlist(as.list(x), recursive = FALSE, use.names = use.names) 27 | else 28 | unlist(x, recursive = FALSE, use.names = use.names) 29 | } 30 | 31 | res = if (recursive) 32 | rapply(as.list(x), f = unpack_recursive) 33 | else 34 | unpack_nonrecursive(x) 35 | 36 | if (!use.names) 37 | names(res) = NULL 38 | 39 | res 40 | } 41 | 42 | -------------------------------------------------------------------------------- /R/utils_index.R: -------------------------------------------------------------------------------- 1 | .assert_index_arg = function(index) 2 | { 3 | if (missing(index)) 4 | stop("'index' is missing", call. = FALSE) 5 | 6 | if (length(index) != 1) 7 | stop("index must be of length 1", call. = FALSE) 8 | 9 | if (is.na(index)) 10 | stop("index must not be 'NA'", call. = FALSE) 11 | } 12 | 13 | .assert_index.character = function(x, index) 14 | { 15 | if (!(utils::hasName(x, index))) 16 | stop("index '", index, "' not found", call. = FALSE) 17 | 18 | invisible(TRUE) 19 | } 20 | 21 | .assert_index.numeric = function(x, index) 22 | { 23 | if (isTRUE(index < 1)) 24 | stop("index must be > 0", call. = FALSE) 25 | 26 | if (index > length(x)) 27 | stop("index ", index, " exceeds length of ", 28 | data.class(x), ", which is ", length(x), call. = FALSE) 29 | 30 | invisible(TRUE) 31 | } 32 | 33 | setGeneric(".assert_index", 34 | function(x, index) standardGeneric(".assert_index")) 35 | 36 | setMethod(".assert_index", 37 | signature("ANY", "character"), .assert_index.character) 38 | 39 | setMethod(".assert_index", 40 | signature("ANY", "numeric"), .assert_index.numeric) 41 | 42 | 43 | .assert_index_and_arg = function(x, index) 44 | { 45 | .assert_index_arg(index) 46 | .assert_index(x, index) 47 | } 48 | 49 | 50 | .has_index = function(x, index) 51 | { 52 | stop("not supported for index of type '", data.class(index), "'") 53 | } 54 | 55 | 56 | .has_index.character = function(x, index) 57 | { 58 | nzchar(index) && utils::hasName(x, index) 59 | } 60 | 61 | .has_index.numeric = function(x, index) 62 | { 63 | isTRUE(index >= 1) && isTRUE(index <= length(x)) 64 | } 65 | 66 | .has_index.integer = function(x, index) 67 | { 68 | isTRUE(index >= 1) && isTRUE(index <= length(x)) 69 | } 70 | 71 | setGeneric(".has_index", function(x, index) standardGeneric(".has_index")) 72 | 73 | setMethod(".has_index", 74 | signature("ANY", "character"), .has_index.character) 75 | 76 | setMethod(".has_index", 77 | signature("ANY", "numeric"), .has_index.numeric) 78 | 79 | setMethod(".has_index", 80 | signature("ANY", "integer"), .has_index.integer) 81 | 82 | .assert_and_has_index = function(x, index) 83 | { 84 | .assert_index_arg(index) 85 | .has_index(x, index) 86 | } 87 | 88 | -------------------------------------------------------------------------------- /R/utils_misc.R: -------------------------------------------------------------------------------- 1 | .is_string = function(x) 2 | { 3 | if (is.null(x)) 4 | return(FALSE) 5 | 6 | if (length(x) != 1) 7 | return(FALSE) 8 | 9 | isTRUE(is.character(x) && !is.na(x)) 10 | } 11 | 12 | .is_nonempty_string = function(x) 13 | { 14 | isTRUE(.is_string(x) && nchar(x) > 0) 15 | } 16 | 17 | 18 | .verify_names = function(x) 19 | { 20 | if (!length(x) || !all(sapply(x, .is_nonempty_string))) 21 | stop("all elements must be named", call. = FALSE) 22 | 23 | invisible(TRUE) 24 | } 25 | 26 | 27 | .check_name_collision = function(x, y) 28 | { 29 | common = intersect(x, y) 30 | 31 | if (!length(common)) 32 | return(invisible(TRUE)) 33 | 34 | if (length(common) == 1) 35 | stop("name ", paste0("'", common, "'"), 36 | " exists already", call. = FALSE) 37 | 38 | stop("names ", toString(paste0("'", common, "'")), 39 | " exist already", call. = FALSE) 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | Implement S3 generics for data.frame 2 | Implement head/tail for container classes and dict.table 3 | Implement coapply to be used like lapply 4 | -------------------------------------------------------------------------------- /docs/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /docs/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /docs/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/apple-touch-icon.png -------------------------------------------------------------------------------- /docs/articles/code-development_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/container_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/deque-set-dict_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/manage-data-columns_files/figure-html/benchmark1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/articles/manage-data-columns_files/figure-html/benchmark1-1.png -------------------------------------------------------------------------------- /docs/articles/manage-data-columns_files/figure-html/benchmark2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/articles/manage-data-columns_files/figure-html/benchmark2-1.png -------------------------------------------------------------------------------- /docs/articles/manage-data-columns_files/figure-html/benchmark3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/articles/manage-data-columns_files/figure-html/benchmark3-1.png -------------------------------------------------------------------------------- /docs/articles/manage-data-columns_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/parameter-list_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/reference-semantics_files/header-attrs-2.11/header-attrs.js: -------------------------------------------------------------------------------- 1 | // Pandoc 2.9 adds attributes on both header and div. We remove the former (to 2 | // be compatible with the behavior of Pandoc < 2.8). 3 | document.addEventListener('DOMContentLoaded', function(e) { 4 | var hs = document.querySelectorAll("div.section[class*='level'] > :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /docs/articles/v04-manage-data-columns_files/figure-html/benchmark1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/articles/v04-manage-data-columns_files/figure-html/benchmark1-1.png -------------------------------------------------------------------------------- /docs/articles/v04-manage-data-columns_files/figure-html/benchmark2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/articles/v04-manage-data-columns_files/figure-html/benchmark2-1.png -------------------------------------------------------------------------------- /docs/articles/v04-manage-data-columns_files/figure-html/benchmark3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/articles/v04-manage-data-columns_files/figure-html/benchmark3-1.png -------------------------------------------------------------------------------- /docs/bootstrap-toc.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v0.4.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | 6 | /* modified from https://github.com/twbs/bootstrap/blob/94b4076dd2efba9af71f0b18d4ee4b163aa9e0dd/docs/assets/css/src/docs.css#L548-L601 */ 7 | 8 | /* All levels of nav */ 9 | nav[data-toggle='toc'] .nav > li > a { 10 | display: block; 11 | padding: 4px 20px; 12 | font-size: 13px; 13 | font-weight: 500; 14 | color: #767676; 15 | } 16 | nav[data-toggle='toc'] .nav > li > a:hover, 17 | nav[data-toggle='toc'] .nav > li > a:focus { 18 | padding-left: 19px; 19 | color: #563d7c; 20 | text-decoration: none; 21 | background-color: transparent; 22 | border-left: 1px solid #563d7c; 23 | } 24 | nav[data-toggle='toc'] .nav > .active > a, 25 | nav[data-toggle='toc'] .nav > .active:hover > a, 26 | nav[data-toggle='toc'] .nav > .active:focus > a { 27 | padding-left: 18px; 28 | font-weight: bold; 29 | color: #563d7c; 30 | background-color: transparent; 31 | border-left: 2px solid #563d7c; 32 | } 33 | 34 | /* Nav: second level (shown on .active) */ 35 | nav[data-toggle='toc'] .nav .nav { 36 | display: none; /* Hide by default, but at >768px, show it */ 37 | padding-bottom: 10px; 38 | } 39 | nav[data-toggle='toc'] .nav .nav > li > a { 40 | padding-top: 1px; 41 | padding-bottom: 1px; 42 | padding-left: 30px; 43 | font-size: 12px; 44 | font-weight: normal; 45 | } 46 | nav[data-toggle='toc'] .nav .nav > li > a:hover, 47 | nav[data-toggle='toc'] .nav .nav > li > a:focus { 48 | padding-left: 29px; 49 | } 50 | nav[data-toggle='toc'] .nav .nav > .active > a, 51 | nav[data-toggle='toc'] .nav .nav > .active:hover > a, 52 | nav[data-toggle='toc'] .nav .nav > .active:focus > a { 53 | padding-left: 28px; 54 | font-weight: 500; 55 | } 56 | 57 | /* from https://github.com/twbs/bootstrap/blob/e38f066d8c203c3e032da0ff23cd2d6098ee2dd6/docs/assets/css/src/docs.css#L631-L634 */ 58 | nav[data-toggle='toc'] .nav > .active > ul { 59 | display: block; 60 | } 61 | -------------------------------------------------------------------------------- /docs/deps/bootstrap-toc-1.0.1/bootstrap-toc.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Table of Contents v1.0.1 (http://afeld.github.io/bootstrap-toc/) 3 | * Copyright 2015 Aidan Feldman 4 | * Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */ 5 | !function(a){"use strict";window.Toc={helpers:{findOrFilter:function(e,t){var n=e.find(t);return e.filter(t).add(n).filter(":not([data-toc-skip])")},generateUniqueIdBase:function(e){return a(e).text().trim().replace(/\'/gi,"").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g,"-").replace(/-{2,}/g,"-").substring(0,64).replace(/^-+|-+$/gm,"").toLowerCase()||e.tagName.toLowerCase()},generateUniqueId:function(e){for(var t=this.generateUniqueIdBase(e),n=0;;n++){var r=t;if(0')},createChildNavList:function(e){var t=this.createNavList();return e.append(t),t},generateNavEl:function(e,t){var n=a('');n.attr("href","#"+e),n.text(t);var r=a("
  • ");return r.append(n),r},generateNavItem:function(e){var t=this.generateAnchor(e),n=a(e),r=n.data("toc-text")||n.text();return this.generateNavEl(t,r)},getTopLevel:function(e){for(var t=1;t<=6;t++){if(1 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/deps/font-awesome-6.5.2/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/deps/font-awesome-6.5.2/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/deps/font-awesome-6.5.2/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.ttf -------------------------------------------------------------------------------- /docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/deps/font-awesome-6.5.2/webfonts/fa-v4compatibility.woff2 -------------------------------------------------------------------------------- /docs/deps/headroom-0.11.0/jQuery.headroom.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * headroom.js v0.9.4 - Give your page some headroom. Hide your header until you need it 3 | * Copyright (c) 2017 Nick Williams - http://wicky.nillia.ms/headroom.js 4 | * License: MIT 5 | */ 6 | 7 | !function(a){a&&(a.fn.headroom=function(b){return this.each(function(){var c=a(this),d=c.data("headroom"),e="object"==typeof b&&b;e=a.extend(!0,{},Headroom.options,e),d||(d=new Headroom(this,e),d.init(),c.data("headroom",d)),"string"==typeof b&&(d[b](),"destroy"===b&&c.removeData("headroom"))})},a("[data-headroom]").each(function(){var b=a(this);b.headroom(b.data())}))}(window.Zepto||window.jQuery); -------------------------------------------------------------------------------- /docs/docsearch.js: -------------------------------------------------------------------------------- 1 | $(function() { 2 | 3 | // register a handler to move the focus to the search bar 4 | // upon pressing shift + "/" (i.e. "?") 5 | $(document).on('keydown', function(e) { 6 | if (e.shiftKey && e.keyCode == 191) { 7 | e.preventDefault(); 8 | $("#search-input").focus(); 9 | } 10 | }); 11 | 12 | $(document).ready(function() { 13 | // do keyword highlighting 14 | /* modified from https://jsfiddle.net/julmot/bL6bb5oo/ */ 15 | var mark = function() { 16 | 17 | var referrer = document.URL ; 18 | var paramKey = "q" ; 19 | 20 | if (referrer.indexOf("?") !== -1) { 21 | var qs = referrer.substr(referrer.indexOf('?') + 1); 22 | var qs_noanchor = qs.split('#')[0]; 23 | var qsa = qs_noanchor.split('&'); 24 | var keyword = ""; 25 | 26 | for (var i = 0; i < qsa.length; i++) { 27 | var currentParam = qsa[i].split('='); 28 | 29 | if (currentParam.length !== 2) { 30 | continue; 31 | } 32 | 33 | if (currentParam[0] == paramKey) { 34 | keyword = decodeURIComponent(currentParam[1].replace(/\+/g, "%20")); 35 | } 36 | } 37 | 38 | if (keyword !== "") { 39 | $(".contents").unmark({ 40 | done: function() { 41 | $(".contents").mark(keyword); 42 | } 43 | }); 44 | } 45 | } 46 | }; 47 | 48 | mark(); 49 | }); 50 | }); 51 | 52 | /* Search term highlighting ------------------------------*/ 53 | 54 | function matchedWords(hit) { 55 | var words = []; 56 | 57 | var hierarchy = hit._highlightResult.hierarchy; 58 | // loop to fetch from lvl0, lvl1, etc. 59 | for (var idx in hierarchy) { 60 | words = words.concat(hierarchy[idx].matchedWords); 61 | } 62 | 63 | var content = hit._highlightResult.content; 64 | if (content) { 65 | words = words.concat(content.matchedWords); 66 | } 67 | 68 | // return unique words 69 | var words_uniq = [...new Set(words)]; 70 | return words_uniq; 71 | } 72 | 73 | function updateHitURL(hit) { 74 | 75 | var words = matchedWords(hit); 76 | var url = ""; 77 | 78 | if (hit.anchor) { 79 | url = hit.url_without_anchor + '?q=' + escape(words.join(" ")) + '#' + hit.anchor; 80 | } else { 81 | url = hit.url + '?q=' + escape(words.join(" ")); 82 | } 83 | 84 | return url; 85 | } 86 | -------------------------------------------------------------------------------- /docs/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/favicon-16x16.png -------------------------------------------------------------------------------- /docs/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/favicon-32x32.png -------------------------------------------------------------------------------- /docs/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/favicon.ico -------------------------------------------------------------------------------- /docs/katex-auto.js: -------------------------------------------------------------------------------- 1 | // https://github.com/jgm/pandoc/blob/29fa97ab96b8e2d62d48326e1b949a71dc41f47a/src/Text/Pandoc/Writers/HTML.hs#L332-L345 2 | document.addEventListener("DOMContentLoaded", function () { 3 | var mathElements = document.getElementsByClassName("math"); 4 | var macros = []; 5 | for (var i = 0; i < mathElements.length; i++) { 6 | var texText = mathElements[i].firstChild; 7 | if (mathElements[i].tagName == "SPAN") { 8 | katex.render(texText.data, mathElements[i], { 9 | displayMode: mathElements[i].classList.contains("display"), 10 | throwOnError: false, 11 | macros: macros, 12 | fleqn: false 13 | }); 14 | }}}); 15 | -------------------------------------------------------------------------------- /docs/link.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /docs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/logo.png -------------------------------------------------------------------------------- /docs/pkgdown.yml: -------------------------------------------------------------------------------- 1 | pandoc: '3.5' 2 | pkgdown: 2.1.1 3 | pkgdown_sha: ~ 4 | articles: 5 | v01-interactive-usage: v01-interactive-usage.html 6 | v02-code-development: v02-code-development.html 7 | v03-parameter-list: v03-parameter-list.html 8 | v04-manage-data-columns: v04-manage-data-columns.html 9 | v05-deque-set-dict: v05-deque-set-dict.html 10 | v06-reference-semantics: v06-reference-semantics.html 11 | last_built: 2025-01-05T18:48Z 12 | urls: 13 | reference: https://github.com/rpahl/container/reference 14 | article: https://github.com/rpahl/container/articles 15 | -------------------------------------------------------------------------------- /docs/reference/!=.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/&.Dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/&.Set.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/+.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/+.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/+.Dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/+.Set.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/-.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/-.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/-.Dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/-.Set.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/==.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/Dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/Rplot001.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/reference/Rplot001.png -------------------------------------------------------------------------------- /docs/reference/[.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/[[.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/add.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/add.Dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/add.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/addleft.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/as.cont.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/as.container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/as.deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/as.dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/as.dict.table.data.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/as.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/as.list.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/as.orderedset.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/as.set.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/at.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/at.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/at2.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/at2.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/begin.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/cbind.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/clear.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/clear.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/clone.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/clone.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/cont.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/count.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/count.Set.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/delete.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/delete_at.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/delete_at.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/discard.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/discard_at.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/discard_at.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/empty.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/empty.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/reference/figures/logo.png -------------------------------------------------------------------------------- /docs/reference/figures/logo2.xcf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/docs/reference/figures/logo2.xcf -------------------------------------------------------------------------------- /docs/reference/getContainerOption.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/get_next.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/get_value.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/has.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/has.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/has_name.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/has_name.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/has_next.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/has_value.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is.container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is.deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is.dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is.iterable.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is.iterator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is.orderedset.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is.set.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is_empty.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/is_empty.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/iter.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/iter.default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/iter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/keys.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/length.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/length.Iterator.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/names.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/next_iter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/peek.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/peek_at.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/peek_at.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/peek_at2.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/peek_at2.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/peekleft.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/peekleft.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/pos.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/rbind.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_add.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_add.Dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_add.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_add.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_addleft.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_addleft.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_clear.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_clear.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_clear.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_delete.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_delete.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_delete_at.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_delete_at.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_delete_at.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_discard.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_discard.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_discard_at.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_discard_at.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_discard_at.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_pop.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_pop.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_pop.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_pop.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_popleft.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_popleft.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_rename.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_rename.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_replace.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_replace.Dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_replace.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_replace_at.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_replace_at.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_replace_at.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_rev.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_rev.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_rotate.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_rotate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_update.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_update.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/ref_update.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/rename.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/rename.default.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/rename.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/replace.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/replace.Dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/replace_at.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/replace_at.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/reset_iter.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/rev.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/rotate.Deque.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/setnew.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/size.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/size.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/sortkey.Dict.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/sortkey.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/update.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/update.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/update.list.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/values.Container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/values.dict.table.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /docs/reference/values.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /inst/tinytest/test_GroupGenericMath.R: -------------------------------------------------------------------------------- 1 | # --------- 2 | # Container 3 | # --------- 4 | ee = expect_equal 5 | ee(abs(container(-2, -1)), container(2, 1)) 6 | ee(exp(log(container(1, 2))), container(1, 2)) 7 | ee(cumsum(container(1, 2, 3)), container(1, 3, 6)) 8 | ee(cumsum(container(3, 2, 1)), container(3, 5, 6)) 9 | 10 | ee(exp(container(1, 2, container(3, 4))), as.container(exp(1:4))) 11 | ee(exp(container(1, 2, list(3, 4))), as.container(exp(1:4))) 12 | ee(exp(container(1, 2, list(container(3), 4))), as.container(exp(1:4))) 13 | ee(exp(container(1, x = 2)), as.container(exp(c(1, x = 2)))) 14 | 15 | ee(cumsum(container(two = 2, one = 1, co = container(one = 1, two = 2))), 16 | container(two = 2, one = 3, co.one = 4, co.two = 6)) 17 | 18 | # ----- 19 | # Deque 20 | # ----- 21 | ee = expect_equal 22 | ee(abs(deque(-1, 1)), deque(1, 1)) 23 | ee(exp(log(deque(1, 2))), deque(1, 2)) 24 | ee(cumsum(deque(1, 2, 3)), deque(1, 3, 6)) 25 | ee(cumsum(deque(3, 2, 1)), deque(3, 5, 6)) 26 | 27 | ee(exp(deque(1, 2, deque(3, 4))), as.deque(exp(1:4))) 28 | ee(exp(deque(1, 2, list(3, 4))), as.deque(exp(1:4))) 29 | ee(exp(deque(1, 2, list(deque(3), 4))), as.deque(exp(1:4))) 30 | 31 | # ---- 32 | # Dict 33 | # ---- 34 | ee = expect_equal 35 | ee(abs(dict(b = -1, a = -2)), dict(a = 2, b = 1)) 36 | ee(exp(log(dict(x = 1, b = 2))), dict(b = 2, x = 1)) 37 | ee(cumsum(dict(a = 1, b = 2, c = 3)), 38 | dict(a = 1, b = 3, c = 6)) 39 | 40 | ee(cumsum(dict(c = 2, b = 1, a = 3)), 41 | dict(a = 3, b = 4, c = 6)) # first sorted then calculated 42 | 43 | ee(abs(dict(a = -1, b = 2, d = dict(a = -3))), 44 | dict(a = 1, b = 2, d.a = 3)) 45 | ee(abs(dict(a = -1, b = 2, d = dict(x = -3))), 46 | dict(a = 1, b = 2, d.x = 3)) 47 | 48 | expect_error(abs(dict(d.a = -1, b = 2, d = dict(a = -3))), "duplicated keys") 49 | 50 | 51 | # --- 52 | # Set 53 | # --- 54 | ee = expect_equal 55 | ee(abs(setnew(-1, 1)), setnew(1, 1)) 56 | ee(exp(log(setnew(1, 2))), setnew(1, 2)) 57 | ee(cumsum(setnew(1, 2, 3)), setnew(1, 3, 6)) 58 | 59 | ee(cumsum(setnew(two = 2, one = 1, s = setnew(one = 1, two = 2))), 60 | setnew(two = 2, one = 3, s.one = 4, s.two = 6)) 61 | 62 | -------------------------------------------------------------------------------- /inst/tinytest/test_Ops-extract.R: -------------------------------------------------------------------------------- 1 | exit_file(msg = "skip for now as some test fails at CRAN") 2 | ee <- expect_equal 3 | 4 | # -------------------- 5 | # Container [ operator 6 | # -------------------- 7 | co <- container(a = 1, 2, b = 3, 4) 8 | ee(co[1], container(a = 1)) 9 | ee(co[2], container(2)) 10 | ee(co["a"], container(a = 1)) 11 | ee(container()[1], container()) 12 | ee(co[""], container()) 13 | ee(co[NULL], container()) 14 | ee(co[integer(0)], container()) 15 | ee(co[0], container()) 16 | ee(co[6], container()) 17 | ee(co[], co) 18 | 19 | ee(co["x"], container()) 20 | ee(co[c("x", "y")], container()) 21 | ee(co[c("a", "y")], container(a = 1)) 22 | 23 | ee(co[1:3], as.container(as.list(co)[1:3])) 24 | ee(co[0:5], co) 25 | 26 | ee(co[c(1, 1)], c(co[1], co[1])) 27 | 28 | ee(co[1, 3], container(a = 1, b = 3)) 29 | ee(co[c(1, 3)], container(a = 1, b = 3)) 30 | ee(co["b", 1, 4], container(b = 3, a = 1, 4)) 31 | ee(co[list("b", 1, 4)], co["b", 1, 4]) 32 | 33 | 34 | # -------------------- 35 | # Container [[ operator 36 | # -------------------- 37 | co <- container(a = 1, 2, b = 3, 4, b = "bar") 38 | 39 | ee(co[[1]], 1) 40 | ee(co[[2]], 2) 41 | ee(co[["a"]], 1) 42 | ee(container()[[1]], NULL) 43 | ee(co[[]], NULL) 44 | ee(co[[0]], NULL) 45 | ee(co[[""]], NULL) 46 | ee(co[[6]], NULL) 47 | ee(co[[NULL]], NULL) 48 | ee(co[[integer(0)]], NULL) 49 | 50 | # list inconsistency 51 | l <- list(a = 1, 2, e = 3) 52 | ee(l[[]], 2) 53 | ee(l[[""]], NULL) 54 | 55 | expect_error(co[[1:2]], "index must be of length 1") 56 | expect_error(co[[c("a", "b")]], "index must be of length 1") 57 | expect_error(co[[NA]], "index must not be 'NA'") -------------------------------------------------------------------------------- /inst/tinytest/test_Ops-replace.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ---------------------- 4 | # Container [<- operator 5 | # ---------------------- 6 | co = container(a = 1, b = "bar") 7 | co[1:2] <- 1:2 8 | ee(co, container(a = 1, b = 2)) 9 | expect_error(co[3] <- 3, "index out of range") 10 | 11 | co[list(1, "b")] <- 3:4 12 | ee(co, container(a = 3, b = 4)) 13 | 14 | co[1:2] <- 0 15 | ee(co, container(a = 0, b = 0)) 16 | 17 | co <- container(1, 2, 3) 18 | expect_warning(co[1:3] <- 1:2, "number of items to replace") 19 | ee(co, container(1, 2, 1)) 20 | expect_warning(co[1] <- 5:6, "number of items to replace") 21 | ee(co, container(5, 2, 1)) 22 | 23 | # ----------------------- 24 | # Container [[<- operator 25 | # ----------------------- 26 | co = container(a = 1, b = "bar") 27 | co[[1]] <- 2 28 | ee(co, container(a = 2, b = "bar")) 29 | co[[2]] <- 9 30 | ee(co, container(a = 2, b = 9)) 31 | 32 | co[["b"]] <- 0 33 | co[["x"]] <- 0 34 | ee(co, container(a = 2, b = 0, x = 0)) 35 | expect_error(co[[4]] <- 1, "index out of range") 36 | 37 | co[[{2}]] <- 1:4 38 | ee(co, container(a = 1:4, b = 0, x = 0)) 39 | 40 | co[[{1:4}]] <- NA 41 | ee(co, container(a = NA, b = 0, x = 0)) 42 | 43 | co[[{NA}]] <- NULL 44 | ee(co, container(a = NULL, b = 0, x = 0)) 45 | 46 | co[[{0}]] <- list(1, "a") 47 | ee(co, container(a = NULL, b = list(1, "a"), x = 0)) 48 | 49 | co[[{list(1, "a")}]] <- 9 50 | ee(co, container(a = NULL, b = 9, x = 0)) 51 | 52 | expect_error(co[[{1}]] <- 9, "old element \\(1\\) is not in Container") 53 | expect_error(co[[1, 2]] <- 3:4) 54 | expect_error(co[[1:2]] <- 3:4, "index must be of length 1") 55 | 56 | # ---------------------- 57 | # Container $<- operator 58 | # ---------------------- 59 | co = container(a = 1, b = "bar") 60 | co$f <- 3 61 | ee(co, container(a = 1, b = "bar", f = 3)) 62 | co$b <- 2 63 | ee(co, container(a = 1, b = 2, f = 3)) 64 | 65 | co$`x 2` <- 0 66 | ee(co[["x 2"]], 0) 67 | 68 | 69 | -------------------------------------------------------------------------------- /inst/tinytest/test_add.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ------------- 4 | # add.Container 5 | # ------------- 6 | x = container(1) 7 | ee(add(x, 2, x = 3), container(1, 2, x = 3)) 8 | x_was_not_touched = all.equal(x, container(1)) 9 | expect_true(x_was_not_touched) 10 | 11 | ref_add(x, 2) 12 | ee(x, container(1, 2)) 13 | 14 | # set 15 | # --- 16 | x = setnew(1) 17 | ee(add(x, 2, x = 3), setnew(1, 2, x = 3)) 18 | x_was_not_touched = all.equal(x, setnew(1)) 19 | expect_true(x_was_not_touched) 20 | 21 | ref_add(x, 2) 22 | ee(x, setnew(1, 2)) 23 | 24 | # deque 25 | # ----- 26 | x = deque(1) 27 | ee(add(x, 2, b = 3), deque(1, 2, b = 3)) 28 | x_was_not_touched = all.equal(x, deque(1)) 29 | expect_true(x_was_not_touched) 30 | 31 | ref_add(x, 2) 32 | ee(x, deque(1, 2)) 33 | 34 | # -------- 35 | # add.Dict 36 | # -------- 37 | d = dict(a = 1) 38 | ee(add(d), d) 39 | ee(add(d, b = 2, x = 4), dict(a = 1, b = 2, x = 4)) 40 | d_was_not_touched = all.equal(d, dict(a = 1)) 41 | expect_true(d_was_not_touched) 42 | 43 | ref_add(d, b = 2, d = 4) 44 | ee(d, dict(a = 1, b = 2, d = 4)) 45 | 46 | expect_error(ref_add(d, z = 9, b = 2), "name 'b' exists already") 47 | 48 | d_was_not_touched_upon_error = all.equal(d, dict(a = 1, b = 2, d = 4)) 49 | expect_true(d_was_not_touched_upon_error) 50 | 51 | 52 | expect_error(add(d, a = 2), "name 'a' exists already") 53 | expect_error(add(d, 2), "all elements must be named") 54 | expect_error(add(d, "a", 2), "all elements must be named") 55 | 56 | # -------------- 57 | # add.dict.table 58 | # -------------- 59 | dit = dict.table(a = 1) 60 | ee(add(dit), dit) 61 | ee(add(dit, b = 2, x = 3), dict.table(a = 1, b = 2, x = 3)) 62 | dit_was_not_touched = all.equal(dit, dict.table(a = 1)) 63 | expect_true(dit_was_not_touched) 64 | 65 | ref_add(dit, b = 2, c = 3) 66 | ee(dit, dict.table(a = 1, b = 2, c = 3)) 67 | 68 | 69 | expect_error(add(dit, d = 4, 5), "all elements must be named") 70 | d_was_not_touched_upon_error = all.equal(dit, dict.table(a = 1, b = 2, c = 3)) 71 | expect_true(d_was_not_touched_upon_error) 72 | 73 | expect_error(add(dit, d = 4, a = 5, b = 6), "names 'a', 'b' exist already") 74 | 75 | -------------------------------------------------------------------------------- /inst/tinytest/test_addleft.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | 4 | # ------------- 5 | # addleft.Deque 6 | # ------------- 7 | d = deque(1, 2, 3) 8 | ee(add(d, n = 0, n1 = 1), deque(1, 2, 3, n = 0, n1 = 1)) 9 | ee(addleft(d, n0 = 0, n1 = 1), 10 | deque(n1 = 1, n0 = 0, 1, 2, 3)) 11 | d_was_not_touched = all.equal(d, as.deque(1:3)) 12 | expect_true(d_was_not_touched) 13 | 14 | ref_addleft(d, 4) 15 | ee(d, deque(4, 1, 2, 3)) 16 | 17 | -------------------------------------------------------------------------------- /inst/tinytest/test_all.equal.R: -------------------------------------------------------------------------------- 1 | # --------- 2 | # container 3 | # --------- 4 | co1 = container(1) 5 | co12 = container(1, 2) 6 | coco = container(3, co12, 4) 7 | 8 | expect_false(all.equal(co1, 1)) 9 | expect_false(all.equal(co1, list(1))) 10 | expect_false(all.equal(co12, coco)) 11 | expect_true(all.equal(coco, coco)) 12 | 13 | c1 = container(1, container(2, v = 1)) 14 | c2 = container(1, container(2, v = 1)) 15 | expect_true(all.equal(c1, c2)) 16 | c2b = container(1, container(2, v = 2)) 17 | expect_false(isTRUE(all.equal(c1, c2b))) 18 | 19 | c1 = container(1, container(2, container(3, data.frame(a = 1, b = 2)))) 20 | c2 = container(1, container(2, container(3, data.frame(a = 1, b = 2)))) 21 | expect_true(all.equal(c1, c2)) 22 | c2b = container(1, container(2, container(3, data.frame(a = 1, b = 3)))) 23 | expect_false(isTRUE(all.equal(c1, c2b))) 24 | 25 | 26 | # ----- 27 | # mixed 28 | # ----- 29 | expect_true(all.equal(dict(a = 1), dict(a = 1))) 30 | expect_false(isTRUE(all.equal(dict(a = 1), dict(b = 1)))) 31 | 32 | d1 = dict(a = 1, b = setnew(1, 2), c = container(3, 4)) 33 | dd = dict(a = 1, b = setnew(1, 2), c = container(3, 4)) 34 | expect_true(all.equal(d1, dd)) 35 | dd = dict(a = 1, b = setnew(1, 2), c = container(3, x = 4)) 36 | expect_false(isTRUE(all.equal(d1, dd))) 37 | 38 | d1 = dict(a = 1, c = container(3, y = setnew(deque(1, 2), deque(3, 4)))) 39 | dd = dict(a = 1, c = container(3, y = setnew(deque(1, 2), deque(3, 4)))) 40 | expect_true(all.equal(d1, dd)) 41 | dd = dict(a = 1, c = container(3, y = setnew(deque(1, 2), deque(4, 3)))) 42 | expect_false(isTRUE(all.equal(d1, dd))) 43 | 44 | # Constructing with copy semantics prevents side effects on the comparison 45 | co1 = container(1) 46 | d1 = dict(a = 1, c = container(3, y = setnew(deque(1, 2), co1))) 47 | dd = dict(a = 1, c = container(3, y = setnew(deque(1, 2), container(1)))) 48 | expect_true(all.equal(d1, dd)) 49 | co1$clear() 50 | expect_true(all.equal(d1, dd)) 51 | 52 | # In contrast, reference semantics yield side effects 53 | co1 = container(1) 54 | d1 = Dict$new(a = 1, c = co1) 55 | dd = Dict$new(a = 1, c = container(1)) 56 | expect_true(all.equal(d1, dd)) 57 | co1$clear() 58 | expect_false(isTRUE(all.equal(d1, dd))) 59 | 60 | -------------------------------------------------------------------------------- /inst/tinytest/test_at.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ----------------- 4 | # at.Container 5 | # ----------------- 6 | co = container(a = 1, 2, b = 3, 4) 7 | ee(at(co, 1), container(a = 1)) 8 | ee(at(co, 2), container(2)) 9 | ee(at(co, "a"), container(a = 1)) 10 | expect_error(at(container(), 1), 11 | "index 1 exceeds length of Container, which is 0") 12 | expect_error(at(co, "x"), "index 'x' not found") 13 | 14 | ee(at(co, 1:3), as.container(as.list(co)[1:3])) 15 | ee(at(co), co) 16 | ee(at(co, NULL), container()) 17 | 18 | ee(at(co, list("a", "b")), at(co, "a", "b")) 19 | expect_error(at(co, list("a", "b", "x")), "index 'x' not found") 20 | 21 | 22 | # ------------- 23 | # at.Dict 24 | # ------------ 25 | d = dict(a = 1, b = 1:3) 26 | ee(at(d, 1, "b"), d) 27 | ee(at(d, "b"), dict(b = 1:3)) 28 | ee(at(d, 1), dict(a = 1)) 29 | ee(at(d, 2), dict(b = 1:3)) 30 | 31 | expect_error(at(d, "x"), "index 'x' not found") 32 | expect_error(at(d, 3, .default = 1), 33 | "index 3 exceeds length of Dict, which is 2") 34 | ee(at(d, list("a", "b")), d) 35 | 36 | 37 | 38 | # ------------------ 39 | # at.dict.table 40 | # ------------------ 41 | dit = dict.table(a = 1:3, b = 4:6) 42 | 43 | expect_error(at(dit, "a", "a"), "duplicated keys") 44 | expect_error(at(dit, 1, 1), "duplicated keys") 45 | expect_error(at(dit, "x"), "index 'x' not found") 46 | expect_error(at(dit, 1:3), 47 | "index 3 exceeds length of dict.table, which is 2") 48 | expect_error(at(d, "a", "b", 9), 49 | "index 9 exceeds length of Dict, which is 2") 50 | expect_error(at(d, "a", "b", "x"), "index 'x' not found") 51 | 52 | ee(at(dit), dit) 53 | ee(at(dit, NULL), dict.table()) 54 | 55 | ee(at(dit, 1:2), dit) 56 | ee(at(dit, list("a", 2)), dit) 57 | ee(at(dit, "a"), dict.table(a = 1:3)) 58 | ee(at(dit, 1), dict.table(a = 1:3)) 59 | 60 | -------------------------------------------------------------------------------- /inst/tinytest/test_at2.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ------------------ 4 | # at2.Container 5 | # ------------------ 6 | co = container(a = 1, 2, b = 3, 4) 7 | ee(at2(co, 1), 1) 8 | ee(at2(co, 2), 2) 9 | ee(at2(co, "a"), 1) 10 | expect_error(at2(container(), 1), 11 | "index 1 exceeds length of Container, which is 0") 12 | expect_error(at2(co), "'index' is missing") 13 | expect_error(at2(co, 1:2), "index must be of length 1") 14 | expect_error(at2(co, "x"), "index 'x' not found") 15 | 16 | # ------------- 17 | # at2.Dict 18 | # ------------- 19 | d = dict(a = 1, b = 2) 20 | ee(at2(d, 1), 1) 21 | ee(at2(d, 2), 2) 22 | ee(at2(d, "a"), 1) 23 | expect_error(at2(dict(), 1), "index 1 exceeds length of Dict, which is 0") 24 | expect_error(at2(d), "'index' is missing") 25 | expect_error(at2(d, 1:2), "index must be of length 1") 26 | expect_error(at2(d, "x"), "index 'x' not found") 27 | 28 | 29 | # ------------------- 30 | # at2.dict.table 31 | # ------------------- 32 | dit = dict.table(a = 1:3, b = 4:6) 33 | ee(at2(dit, "a"), 1:3) 34 | ee(at2(dit, 1), 1:3) 35 | expect_error(at2(dict.table(), 1), 36 | "index 1 exceeds length of dict.table, which is 0") 37 | expect_error(at2(dit), "'index' is missing") 38 | expect_error(at2(dit, 1:2), "index must be of length 1") 39 | expect_error(at2(dit, "x"), "index 'x' not found") 40 | 41 | -------------------------------------------------------------------------------- /inst/tinytest/test_clear.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # --------------- 4 | # clear.Container 5 | # --------------- 6 | co = container(1, 2, mean) 7 | ee(clear(co), container()) 8 | expect_false(is_empty(co)) 9 | ee(ref_clear(co), container()) 10 | expect_true(is_empty(co)) 11 | 12 | # ---------------- 13 | # clear.dict.table 14 | # ---------------- 15 | dit = dict.table(a = 1, b = 2) 16 | ee(clear(dit), dict.table()) 17 | expect_false(is_empty(dit)) 18 | ee(ref_clear(dit), dict.table()) 19 | expect_true(is_empty(dit)) 20 | 21 | -------------------------------------------------------------------------------- /inst/tinytest/test_clone.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # --------------- 4 | # clone.Container 5 | # --------------- 6 | co = container(1, 2, mean) 7 | co2 = clone(co) 8 | ee(co2, co) 9 | ref_clear(co) 10 | expect_true(is_empty(co)) 11 | expect_false(is_empty(co2)) 12 | 13 | # ---------------- 14 | # clone.dict.table 15 | # ---------------- 16 | dit = dict.table(a = 1, b = 2) 17 | dit2 = clone(dit) 18 | ee(dit2, dit) 19 | ref_clear(dit) 20 | expect_true(is_empty(dit)) 21 | expect_false(is_empty(dit2)) 22 | 23 | -------------------------------------------------------------------------------- /inst/tinytest/test_container-deprecated.R: -------------------------------------------------------------------------------- 1 | # verify that functions are deprecated 2 | co <- Container$new(1L) 3 | expect_warning(co$empty(), "deprecated") 4 | expect_warning(co$remove(), "deprecated") 5 | expect_warning(co$size(), "deprecated") 6 | expect_warning(co$type(), "deprecated") 7 | 8 | # Dict set is deprecated and replaced by replace 9 | d <- Dict$new(a = 1, b = 2) 10 | expect_warning(d$set("b", 9), "Use 'replace' instead.") 11 | expect_equal(d$at2("b"), 9) 12 | 13 | # Dict remove is deprecated and replaced by delete 14 | d <- Dict$new(a = 1, b = 2) 15 | expect_warning(d$remove("b"), "Use 'delete' instead.") 16 | expect_false(d$has("b")) 17 | 18 | # Dict sort is deprecated 19 | d <- Dict$new(b = 1, a = 2) 20 | expect_warning(d$sort(), "'sort' is deprecated - keys are now always sorted") 21 | 22 | expect_warning(keys(dict()), "'keys' is deprecated.") 23 | 24 | d <- Dict$new(b = 1, a = 2) 25 | expect_warning(sortkey(d), 26 | "'sort' is deprecated - keys are now always sorted") 27 | -------------------------------------------------------------------------------- /inst/tinytest/test_count.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # --------------- 4 | # count.Container 5 | # --------------- 6 | co = container("a", "b", "a", mean, mean, NULL) 7 | ee(count(co, "a"), 2) 8 | ee(count(co, mean), 2) 9 | ee(count(co, "c"), 0) 10 | ee(count(co, NA), 0) 11 | ee(count(co, NULL), 1) 12 | ee(count(clear(co), "a"), 0) 13 | 14 | 15 | # ---------------- 16 | # clone.dict.table 17 | # ---------------- 18 | s = setnew("a", "b", "a", mean, mean) 19 | ee(count(s, "a"), 1) 20 | ee(count(s, mean), 1) 21 | ee(count(s, "c"), 0) 22 | ee(count(clear(s), "a"), 0) 23 | 24 | -------------------------------------------------------------------------------- /inst/tinytest/test_delete.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ---------------- 4 | # delete.Container 5 | # ---------------- 6 | co = container("a", "b", "a", mean, mean, NULL) 7 | co2 = clone(co) 8 | ee(delete(co), co2) 9 | ee(delete(co, "a", mean, NULL), container("b", "a", mean)) 10 | original_was_not_touched = ee(co, co2) 11 | expect_true(original_was_not_touched) 12 | 13 | ee(ref_delete(co, "a", mean, NULL), container("b", "a", mean)) 14 | delete_was_done_on_original = ee(co, container("b", "a", mean)) 15 | expect_true(delete_was_done_on_original) 16 | 17 | co2 = clone(co) 18 | expect_error(ref_delete(co, "a", "x"), '"x" is not in Container') 19 | was_not_touched_on_error = ee(co, co2) 20 | expect_true(was_not_touched_on_error) 21 | 22 | expect_silent(ref_delete(co, "a")) 23 | 24 | d = dict(a = 1, b = 2, f = mean) 25 | d2 = clone(d) 26 | ee(delete(d, 1, 2, mean), dict()) 27 | original_was_not_touched = ee(d, d2) 28 | expect_true(original_was_not_touched) 29 | 30 | -------------------------------------------------------------------------------- /inst/tinytest/test_discard.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ----------------- 4 | # discard.Container 5 | # ----------------- 6 | co = container("a", "b", "a", mean, mean, NULL) 7 | co2 = clone(co) 8 | ee(discard(co), co2) 9 | ee(discard(co, "a", mean, NULL), container("b", "a", mean)) 10 | original_was_not_touched = ee(co, co2) 11 | expect_true(original_was_not_touched) 12 | 13 | ee(ref_discard(co, "a", mean, NULL), container("b", "a", mean)) 14 | discard_was_done_on_original = ee(co, container("b", "a", mean)) 15 | expect_true(discard_was_done_on_original) 16 | ee(discard(co, "x"), co) 17 | 18 | co2 = clone(co) 19 | nothing_was_removed = ee(co, co2) 20 | expect_true(nothing_was_removed) 21 | 22 | d = dict(a = 1, b = 2, f = mean) 23 | d2 = clone(d) 24 | ee(discard(d, 1, 2, mean), dict()) 25 | original_was_not_touched = ee(d, d2) 26 | expect_true(original_was_not_touched) 27 | ee(discard(d, "x"), d) 28 | 29 | -------------------------------------------------------------------------------- /inst/tinytest/test_discard_at.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ----------------- 4 | # discard.Container 5 | # ----------------- 6 | co = container(a = 1, b = 2, f = mean, 3) 7 | co2 = clone(co) 8 | ee(discard_at(co), co2) 9 | ee(discard_at(co, "a"), container(b = 2, f = mean, 3)) 10 | original_was_not_touched = ee(co, co2) 11 | expect_true(original_was_not_touched) 12 | 13 | ee(discard_at(co, "a"), discard_at(co, 1)) 14 | ee(discard_at(co, "b"), discard_at(co, 2)) 15 | ee(discard_at(co, 1:4), container()) 16 | 17 | ee(discard_at(co, "b", "a", 4:3, 1), container()) 18 | ee(discard_at(co, "a", 1), discard_at(co, 1)) 19 | 20 | ee(discard_at(co, "a", "x"), discard_at(co, "a")) 21 | ee(discard_at(co, "x", "a"), discard_at(co, "a")) 22 | ee(discard_at(co, "a", 5), discard_at(co, "a")) 23 | ee(discard_at(co, 6, "a", 5), discard_at(co, "a")) 24 | 25 | ee(ref_discard_at(co, 1:4), container()) 26 | ee(co, container()) 27 | 28 | # discard_at.Dict 29 | d = dict(a = 1, b = 2, f = mean) 30 | d2 = clone(d) 31 | ee(discard_at(d, "a", "f", "b"), dict()) 32 | original_was_not_touched = ee(d, d2) 33 | expect_true(original_was_not_touched) 34 | 35 | # args as character vector 36 | expect_true(is_empty(discard_at(d, names(d)))) 37 | 38 | ee(ref_discard_at(d, "a", "f", "b"), dict()) 39 | discard_was_done_on_original = ee(d, dict()) 40 | expect_true(discard_was_done_on_original) 41 | 42 | 43 | 44 | # ------------------ 45 | # discard.dict.table 46 | # ------------------ 47 | d = dict.table(a = 1, b = 2, f = mean) 48 | d2 = clone(d) 49 | expect_true(is_empty(discard_at(d, 1, "b", 3))) 50 | expect_true(is_empty(discard_at(d, 1:3))) 51 | expect_true(is_empty(discard_at(d, 3:1))) 52 | ee(d, d2) 53 | 54 | # args as character vector 55 | expect_true(is_empty(discard_at(d, colnames(d)))) 56 | expect_true(is_empty(discard_at(d, rev(colnames(d))))) 57 | ee(d, d2) 58 | 59 | expect_silent(ref_discard_at(d, "x", 4, 11)) 60 | d_was_not_altered = ee(d, d2) 61 | expect_true(d_was_not_altered) 62 | 63 | ee(ref_discard_at(d, "b"), d2[, c(1, 3)]) 64 | expect_silent(ref_discard_at(d, "a")) 65 | expect_false(ncol(d) == ncol(d2)) 66 | 67 | -------------------------------------------------------------------------------- /inst/tinytest/test_format.R: -------------------------------------------------------------------------------- 1 | # ------------- 2 | # format values 3 | # ------------- 4 | ee = expect_equal 5 | f = container:::.format_values 6 | 7 | expect_error(f()) 8 | ee(f(NA), "(NA)") 9 | ee(f(list(NULL)), "(NULL)") 10 | ee(f(list(mean)), "(<>)") 11 | 12 | ee(f(as.list(1:10)), "(1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L)") 13 | ee(f(list(a = 1, b = 1:10)), "(a = 1, b = (1L 2L 3L 4L ...))") 14 | ee(f(list(b = 1:10, m = matrix(1:6, nrow = 2))), 15 | '(b = (1L 2L 3L 4L ...), m = <>)') 16 | ee(f(list(b = 1:10, m = matrix(1:6, nrow = 2))), 17 | '(b = (1L 2L 3L 4L ...), m = <>)') 18 | 19 | 20 | # ---------------- 21 | # format.Container 22 | # ---------------- 23 | f = container:::format.Container 24 | ee(f(container()), "[]") 25 | ee(f(container(NULL)), "[NULL]") 26 | ee(f(container(integer())), "[integer()]") 27 | ee(f(container(numeric())), "[numeric()]") 28 | ee(f(container(1, b = 2)), "[1, b = 2]") 29 | ee(f(container(list(a = 1, x = 1:2))), "[list(a = 1, x = (1L 2L))]") 30 | ee(f(container(list(x = 1:40))), "[list(x = (1L 2L 3L 4L ...))]") 31 | 32 | co = container(1, 2) 33 | ee(f(container(co, list(x = co, 3))), '[[1, 2], list(x = [1, 2], 3)]') 34 | ee(f(container(co, s = setnew(co), 3)), '[[1, 2], s = {[1, 2]}, 3]') 35 | 36 | 37 | # ----------- 38 | # format.Dict 39 | # ----------- 40 | f = container:::format.Dict 41 | ee(f(dict(a = 1, b = 2:3, c = container(), d = deque(4, 1))), 42 | "{a = 1, b = (2L 3L), c = Container(), d = |4, 1|}") 43 | 44 | # ------------ 45 | # format.Deque 46 | # ------------ 47 | f = container:::format.Deque 48 | ee(f(deque(2, 3, 1)), "|2, 3, 1|") 49 | 50 | 51 | # ---------- 52 | # format.Set 53 | # ---------- 54 | f = container:::format.Set 55 | ee(f(setnew(2, 3, 1)), "{2, 3, 1}") 56 | 57 | -------------------------------------------------------------------------------- /inst/tinytest/test_has.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # --------------- 4 | # has.Container 5 | # --------------- 6 | co = container(1, 2, mean) 7 | expect_true(has(co, 1)) 8 | expect_true(has(co, mean)) 9 | expect_false(has(co, 1:2)) 10 | expect_false(has(co, NA)) 11 | expect_false(has(co, NULL)) 12 | 13 | # -------- 14 | # has.Dict 15 | # -------- 16 | d = dict(a = 1, b = 3) 17 | expect_false(has(d, "a")) 18 | expect_true(has(d, 1)) 19 | expect_false(has(d, 2)) 20 | 21 | # ---------------- 22 | # has.dict.table 23 | # ---------------- 24 | dit = dict.table(a = 1:3, b = as.list(4:6)) 25 | 26 | expect_true(has(dit, 1:3)) 27 | expect_false(has(dit, 4:6)) 28 | expect_true(has(dit, as.list(4:6))) 29 | 30 | expect_warning(has(dit, 1:2), 31 | "length of column vector \\(2\\) does not match number of rows \\(3\\)") 32 | 33 | 34 | -------------------------------------------------------------------------------- /inst/tinytest/test_has_name.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ------------------ 4 | # has_name.Container 5 | # ------------------ 6 | co = container(a = 1, 2, f = mean) 7 | expect_true(has_name(co)) 8 | expect_false(has_name(container())) 9 | expect_true(has_name(co, "a")) 10 | expect_true(has_name(co, "f")) 11 | expect_false(has_name(co, "2")) 12 | 13 | 14 | # ------------------- 15 | # has_name.dict.table 16 | # ------------------- 17 | dit = dict.table(a = 1:2, b = 3:4) 18 | 19 | expect_true(has_name(dit, "a")) 20 | expect_false(has_name(dit, "x")) 21 | 22 | EE = expect_error 23 | EE(has_name(dit, NULL), "name must be a character string, but got 'NULL'") 24 | EE(has_name(dit, c("a", "b")), "name must be of length 1") 25 | EE(has_name(dit, as.character(NA)), "undefined name") 26 | EE(has_name(dit, ""), "name must consist of at least one character") 27 | 28 | -------------------------------------------------------------------------------- /inst/tinytest/test_is_empty.R: -------------------------------------------------------------------------------- 1 | # ------------------ 2 | # is_empty.Container 3 | # ------------------ 4 | co = container(1, 2) 5 | expect_false(is_empty(co)) 6 | expect_true(is_empty(clear(co))) 7 | 8 | # ------------------- 9 | # is_empty.dict.table 10 | # ------------------- 11 | d = dict.table(a = 1:4, b = 4:1) 12 | expect_false(is_empty(d)) 13 | expect_true(is_empty(clear(d))) 14 | 15 | -------------------------------------------------------------------------------- /inst/tinytest/test_options.R: -------------------------------------------------------------------------------- 1 | # ----------------- 2 | # container_options 3 | # ----------------- 4 | 5 | defaults = container:::.default_options 6 | co = container_options 7 | co(.reset = TRUE) 8 | 9 | 10 | # With no arg all options should be returned 11 | expect_equal(co(), defaults()) 12 | 13 | # Several at once 14 | expect_equal(co("compare", "vec.len"), 15 | defaults()[c("compare", "vec.len")]) 16 | expect_equal(co("compare", "foo"), defaults()["compare"]) 17 | 18 | co("zzz" = "foo") 19 | expect_equal(co("zzz"), list(zzz = "foo")) 20 | 21 | expect_equal(co(), c(defaults(), list(zzz = "foo"))) 22 | co(zzz = NULL) 23 | expect_equal(co(), defaults()) 24 | 25 | # Set several options at once 26 | old = co(compare = "identical", useDots = FALSE) 27 | expect_equal(old, defaults()) 28 | 29 | expect_equal(co(), replace(defaults(), 30 | c("compare", "useDots"), 31 | list("identical", FALSE))) 32 | 33 | co(.reset = TRUE) 34 | expect_equal(co(), defaults()) 35 | 36 | # Verify that options are sorted 37 | container_options(".aa" = 1, "zzz" = 2) 38 | expect_equal(co(), c(list(.aa = 1), defaults(), list(zzz = 2))) 39 | 40 | 41 | # ------------------ 42 | # getContainerOption 43 | # ------------------ 44 | expect_equal(getContainerOption("useDots"), container_options()[["useDots"]]) 45 | expect_equal(getContainerOption("compare"), container_options()[["compare"]]) 46 | 47 | expect_equal(getContainerOption("bla"), NULL) 48 | expect_equal(getContainerOption("bla", default = 1), 1) 49 | 50 | expect_error(getContainerOption(c("useDots", "compare")), 51 | "'x' must be a character string") 52 | 53 | -------------------------------------------------------------------------------- /inst/tinytest/test_peek.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | 4 | d = deque(1, 2, 3) 5 | ee(peek(d), 3) 6 | ee(peekleft(d), 1) 7 | ee(peek(deque()), NULL) 8 | ee(peekleft(deque()), NULL) 9 | ee(peek(deque(), default = 1), 1) 10 | ee(peekleft(deque(), default = 0), 0) 11 | ee(peek_at2(d), NULL) 12 | ee(peek_at2(d, default = 1), 1) 13 | 14 | 15 | -------------------------------------------------------------------------------- /inst/tinytest/test_peek_at2.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ------------------ 4 | # peek_at2.Container 5 | # ------------------ 6 | co = container(a = 1, 2, b = 3, 4) 7 | ee(peek_at2(co, 1), 1) 8 | ee(peek_at2(co, 2), 2) 9 | ee(peek_at2(co, "a"), 1) 10 | ee(peek_at2(container(), 1), NULL) 11 | ee(peek_at2(container(), 1, default = 0), 0) 12 | ee(peek_at2(co), NULL) 13 | ee(peek_at2(co, default = 1), 1) 14 | 15 | expect_error(peek_at2(co, 1:2), "index must be of length 1") 16 | expect_error(peek_at2(co, c("a", "b")), "index must be of length 1") 17 | expect_error(peek_at2(co, NA), "index must not be 'NA'") 18 | 19 | # ------------- 20 | # peek_at2.Dict 21 | # ------------- 22 | d = dict(a = 1, b = 1:3) 23 | ee(peek_at2(d, "b"), 1:3) 24 | ee(peek_at2(d, "x"), NULL) 25 | ee(peek_at2(d, "x", default = 4:6), 4:6) 26 | ee(peek_at2(d, 1), 1) 27 | ee(peek_at2(d, 2), 1:3) 28 | ee(peek_at2(d), NULL) 29 | ee(peek_at2(d, default = 1), 1) 30 | 31 | 32 | # -------------- 33 | # peek_at2.Deque 34 | # -------------- 35 | d = deque(1, 2, 3) 36 | ee(peek(d), 3) 37 | ee(peekleft(d), 1) 38 | ee(peek(deque()), NULL) 39 | ee(peekleft(deque()), NULL) 40 | ee(peek(deque(), default = 1), 1) 41 | ee(peekleft(deque(), default = 0), 0) 42 | ee(peek_at2(d), NULL) 43 | ee(peek_at2(d, default = 1), 1) 44 | 45 | 46 | # ------------------- 47 | # peek_at2.dict.table 48 | # ------------------- 49 | dit = dict.table(a = 1:3, b = 4:6) 50 | ee(peek_at2(dit, "a"), 1:3) 51 | ee(peek_at2(dit, 1), 1:3) 52 | ee(peek_at2(dit, 3), NULL) 53 | ee(peek_at2(dit, "x"), NULL) 54 | ee(peek_at2(dit, "x", default = 0), rep(0, 3)) 55 | 56 | expect_error(peek_at2(dit, 1:2), "index must be of length 1") 57 | expect_error(peek_at2(dit, NA), "index must not be 'NA'") 58 | 59 | expect_warning(peek_at2(dit, "x", default = 1:2), 60 | "did not match number of rows") 61 | 62 | -------------------------------------------------------------------------------- /inst/tinytest/test_pop.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ---------- 4 | # pop_.Deque 5 | # ---------- 6 | d = deque(1, 2, 3) 7 | ee(ref_pop(d), 3) 8 | ee(ref_popleft(d), 1) 9 | ee(d, deque(2)) 10 | 11 | expect_error(ref_pop(deque()), "pop at empty Deque") 12 | expect_error(ref_popleft(deque()), "popleft at empty Deque") 13 | 14 | 15 | # ----------------- 16 | # ref_pop.Container 17 | # ----------------- 18 | co = container(a = 1, b = 1:3, d = "foo") 19 | 20 | ee(ref_pop(co, "b"), 1:3) 21 | ee(ref_pop(co, "a"), 1) 22 | expect_error(ref_pop(co, "x"), "index 'x' not found") 23 | 24 | 25 | # ------------ 26 | # ref_pop.Dict 27 | # ------------ 28 | d = dict(a = 1, b = 1:3) 29 | expect_error(ref_pop(d, "x"), "index 'x' not found") 30 | 31 | ee(ref_pop(d, "b"), 1:3) 32 | ee(ref_pop(d, "a"), 1) 33 | expect_error(ref_pop(d, "x"), "pop at empty Dict") 34 | 35 | 36 | # ------------------ 37 | # ref_pop.dict.table 38 | # ------------------ 39 | dit = dict.table(a = 1:3, b = 4:6) 40 | 41 | ee(ref_pop(dit, "a"), 1:3) 42 | ee(ref_pop(dit, 1), 4:6) 43 | expect_error(ref_pop(dit, 1), "index 1 exceeds length of dict.table, which is 0") 44 | expect_error(ref_pop(dit, "z"), "index 'z' not found") 45 | 46 | -------------------------------------------------------------------------------- /inst/tinytest/test_rev.R: -------------------------------------------------------------------------------- 1 | 2 | # --------- 3 | # rev.Deque 4 | # --------- 5 | v = 1:5 6 | d = as.deque(v) 7 | expect_equal(unpack(d), v) 8 | 9 | expect_equal(unpack(rev(d)), rev(v)) 10 | d_was_changed = !identical(unpack(d), v) 11 | expect_false(d_was_changed) 12 | 13 | expect_equal(unpack(ref_rev(d)), rev(v)) 14 | expect_equal(unpack(d), rev(v)) 15 | 16 | -------------------------------------------------------------------------------- /inst/tinytest/test_rotate.R: -------------------------------------------------------------------------------- 1 | ee = expect_equal 2 | 3 | # ------------ 4 | # rotate.Deque 5 | # ------------ 6 | d = deque(1, 2, 3, 4) 7 | ee(rotate(d), deque(4, 1, 2, 3)) 8 | ee(rotate(d, 2), deque(3, 4, 1, 2)) 9 | ee(rotate(d, -1), deque(2, 3, 4, 1)) 10 | 11 | # by reference 12 | ref_rotate(d) 13 | ee(d, deque(4, 1, 2, 3)) 14 | 15 | ref_rotate(d, -1) 16 | ee(d, deque(1, 2, 3, 4)) 17 | 18 | -------------------------------------------------------------------------------- /inst/tinytest/test_unpack.R: -------------------------------------------------------------------------------- 1 | # ------ 2 | # unpack 3 | # ------ 4 | # Verify equality to unlist if only using list arguments 5 | check = function(x, ...) { 6 | expect_equal(unpack(x, ...), unlist(x, ...)) 7 | } 8 | 9 | check(NULL) 10 | check(numeric()) 11 | check(list()) 12 | check(c(a = 1)) 13 | check(c(a = 1), use.names = FALSE) 14 | check(list(a = 1)) 15 | check(list(a = 1, 2)) 16 | check(list(a = 1, 2, use.names = FALSE)) 17 | 18 | l = list(a = list(b = 1:5, ll = list(0, x = NULL, 1))) 19 | check(l) 20 | check(l, recursive = FALSE) 21 | check(l, use.names = FALSE) 22 | check(l, recursive = FALSE, use.names = FALSE) 23 | 24 | 25 | # container vs list 26 | check = function(x, y, ...) { 27 | expect_equal(unpack(x, ...), unlist(y, ...)) 28 | } 29 | 30 | check(container(), list()) 31 | check(container(), list(), recursive = FALSE) 32 | check(container(NULL), list(NULL)) 33 | check(container(container()), list(list())) 34 | check(container(co = container()), list(co = container()), recursive = FALSE) 35 | 36 | daf = data.frame(A = 1:2, B = 3:4) 37 | check(container(daf = daf), list(daf = daf)) 38 | check(container(daf = daf), list(daf = daf), use.names = FALSE) 39 | check(container(daf = daf), list(daf = daf), recursive = FALSE) 40 | 41 | co <- container(a = 1, b = 2) 42 | check(container(co = co), list(co = co), recursive = FALSE) 43 | expect_equal(unpack(container(co = co)), c(co.a = 1, co.b = 2)) 44 | 45 | 46 | # nested containers 47 | co <- container(co = container(0), 48 | s = setnew(1, 2), 49 | d = dict(a = 1, b = 9), 50 | de = as.deque(5:6)) 51 | expect_equal(unpack(co), 52 | c(co = 0, s1 = 1, s2 = 2, d.a = 1, d.b = 9, de1 = 5, de2 = 6)) 53 | 54 | 55 | -------------------------------------------------------------------------------- /inst/tinytest/test_utils_index.R: -------------------------------------------------------------------------------- 1 | # ------------- 2 | # .assert_index_and_arg 3 | # ------------- 4 | f = container:::.assert_index_and_arg 5 | co = container(1, 2, 3) 6 | 7 | expect_error(f(co, 4), "index 4 exceeds length of Container, which is 3") 8 | expect_error(f(1:3, 4), "index 4 exceeds length of numeric, which is 3") 9 | expect_error(f(co, "a"), "index 'a' not found") 10 | expect_error(f(co, 1:2), "index must be of length 1") 11 | expect_error(f(co, NULL), "index must be of length 1") 12 | expect_error(f(co, list(1))) 13 | expect_error(f(co, index = NA), "index must not be 'NA'") 14 | 15 | 16 | expect_true(f(co, 3)) 17 | expect_true(f(c(a = 1), "a")) 18 | expect_true(f(list(a = 1), "a")) 19 | expect_true(f(list(a = 1), "a")) 20 | 21 | 22 | # --------------------- 23 | # .assert_and_has_index 24 | # --------------------- 25 | f = container:::.assert_and_has_index 26 | co = container(a = 1, 2) 27 | 28 | expect_false(f(co, 0)) 29 | expect_true(f(co, 1)) 30 | expect_true(f(co, 2)) 31 | expect_false(f(co, 3)) 32 | 33 | expect_true(f(co, "a")) 34 | expect_false(f(co, "b")) 35 | 36 | expect_error(f(co, list(1))) 37 | expect_error(f(co, index = 1:2), "index must be of length 1") 38 | expect_error(f(co, index = NA), "index must not be 'NA'") 39 | 40 | 41 | l = list(a = 1, 2) 42 | expect_false(container:::.has_index(l, "")) 43 | 44 | -------------------------------------------------------------------------------- /inst/tinytest/test_utils_misc.R: -------------------------------------------------------------------------------- 1 | # ---------- 2 | # .is_string 3 | # ---------- 4 | f = container:::.is_string 5 | expect_false(f(1)) 6 | expect_false(f(NULL)) 7 | expect_false(f(NA)) 8 | expect_false(f(character())) 9 | expect_false(f(as.character(NA))) 10 | expect_false(f(c("a", "b"))) 11 | expect_true(f("")) 12 | expect_true(f("a")) 13 | expect_true(f("1")) 14 | 15 | # ------------------- 16 | # .is_nonempty_string 17 | # ------------------- 18 | f = container:::.is_nonempty_string 19 | expect_false(f(1)) 20 | expect_false(f(NULL)) 21 | expect_false(f(NA)) 22 | expect_false(f(character())) 23 | expect_false(f(as.character(NA))) 24 | expect_false(f(c("a", "b"))) 25 | expect_false(f("")) 26 | expect_true(f("a")) 27 | expect_true(f("1")) 28 | 29 | # ------------- 30 | # .verify_names 31 | # ------------- 32 | f = container:::.verify_names 33 | expect_error(f(NULL)) 34 | expect_error(f("")) 35 | expect_error(f(c(NA, NA))) 36 | expect_true(f("a")) 37 | 38 | 39 | # --------------------- 40 | # .check_name_collision 41 | # --------------------- 42 | ee = expect_error 43 | f = container:::.check_name_collision 44 | expect_true(f("a", "b")) 45 | ee(f("a", "a"), "name 'a' exists already") 46 | ee(f(c("a", "b"), c("b", "c")), "name 'b' exists already") 47 | ee(f(c("a", "b"), c("b", "a")), 48 | "names 'a', 'b' exist already") 49 | 50 | -------------------------------------------------------------------------------- /man/Iterable.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/0-ContainerR6.R 3 | \docType{class} 4 | \name{Iterable} 5 | \alias{Iterable} 6 | \title{Iterable abstract class interface} 7 | \description{ 8 | An \link{Iterable} is an object that provides an \code{\link[=iter]{iter()}} method, 9 | which is expected to return an \link{Iterator} object. This class defines the 10 | abstract class interface such that each class inheriting this class provides 11 | an \code{\link[=iter]{iter()}} method and must implement a private method \code{create_iter()}, 12 | which must return an \link{Iterator} object. 13 | } 14 | \seealso{ 15 | \link{Iterator} and \link{Container} 16 | } 17 | \author{ 18 | Roman Pahl 19 | } 20 | \section{Methods}{ 21 | \subsection{Public methods}{ 22 | \itemize{ 23 | \item \href{#method-Iterable-new}{\code{Iterable$new()}} 24 | \item \href{#method-Iterable-iter}{\code{Iterable$iter()}} 25 | \item \href{#method-Iterable-clone}{\code{Iterable$clone()}} 26 | } 27 | } 28 | \if{html}{\out{
    }} 29 | \if{html}{\out{}} 30 | \if{latex}{\out{\hypertarget{method-Iterable-new}{}}} 31 | \subsection{Method \code{new()}}{ 32 | \code{Iterable} is an abstract class and thus cannot be instantiated. 33 | \subsection{Usage}{ 34 | \if{html}{\out{
    }}\preformatted{Iterable$new()}\if{html}{\out{
    }} 35 | } 36 | 37 | } 38 | \if{html}{\out{
    }} 39 | \if{html}{\out{}} 40 | \if{latex}{\out{\hypertarget{method-Iterable-iter}{}}} 41 | \subsection{Method \code{iter()}}{ 42 | Create iterator 43 | \subsection{Usage}{ 44 | \if{html}{\out{
    }}\preformatted{Iterable$iter()}\if{html}{\out{
    }} 45 | } 46 | 47 | \subsection{Returns}{ 48 | returns the \code{Iterator} object. 49 | } 50 | } 51 | \if{html}{\out{
    }} 52 | \if{html}{\out{}} 53 | \if{latex}{\out{\hypertarget{method-Iterable-clone}{}}} 54 | \subsection{Method \code{clone()}}{ 55 | The objects of this class are cloneable with this method. 56 | \subsection{Usage}{ 57 | \if{html}{\out{
    }}\preformatted{Iterable$clone(deep = FALSE)}\if{html}{\out{
    }} 58 | } 59 | 60 | \subsection{Arguments}{ 61 | \if{html}{\out{
    }} 62 | \describe{ 63 | \item{\code{deep}}{Whether to make a deep clone.} 64 | } 65 | \if{html}{\out{
    }} 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /man/OpsCompare.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Ops-compare.R 3 | \name{OpsCompare} 4 | \alias{OpsCompare} 5 | \alias{==.Container} 6 | \alias{!=.Container} 7 | \alias{<.Container} 8 | \alias{>.Container} 9 | \alias{<=.Container} 10 | \alias{>=.Container} 11 | \title{Comparison Operators} 12 | \usage{ 13 | \method{==}{Container}(x, y) 14 | 15 | \method{!=}{Container}(x, y) 16 | 17 | \method{<}{Container}(x, y) 18 | 19 | \method{>}{Container}(x, y) 20 | 21 | \method{<=}{Container}(x, y) 22 | 23 | \method{>=}{Container}(x, y) 24 | } 25 | \arguments{ 26 | \item{x, y}{at least one must be a \code{\link[=Container]{Container()}} object (or an object of 27 | one of the derived classes) while the other must be at least iterable.} 28 | } 29 | \description{ 30 | Binary comparison operators for \code{\link[=Container]{Container()}} objects and 31 | derived classes. 32 | } 33 | \details{ 34 | \itemize{ 35 | \item \code{x == y} is \code{TRUE} if the contents of \code{x} and \code{y} are lexicographically \emph{equal}. 36 | \item \code{x != y} is \code{TRUE} if the contents of \code{x} and \code{y} are \emph{not equal}. 37 | \item \code{x < y} is \code{TRUE} if the contents of x are lexicographically \emph{less} than the 38 | contents of y. 39 | \item \code{x <= y} is \code{TRUE} if the contents of x are lexicographically \emph{less} than 40 | or \emph{equal} to the contents of y. 41 | } 42 | } 43 | \examples{ 44 | c1 = container(1, 2, 3) 45 | c2 = container(1, 3, 2) 46 | c1 == c1 # TRUE 47 | c1 != c2 # TRUE 48 | c1 <= c1 # TRUE 49 | c1 == c2 # FALSE 50 | c1 < c2 # TRUE 51 | c1 < container(2) # TRUE 52 | c1 < container() # FALSE 53 | 54 | } 55 | -------------------------------------------------------------------------------- /man/OpsExtract.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Ops-extract.R 3 | \name{OpsExtract} 4 | \alias{OpsExtract} 5 | \alias{[.Container} 6 | \alias{[[.Container} 7 | \title{Extract Parts of a Container Object} 8 | \usage{ 9 | \method{[}{Container}(x, ...) 10 | 11 | \method{[[}{Container}(x, i) 12 | } 13 | \arguments{ 14 | \item{x}{\code{Container} object from which to extract elements.} 15 | 16 | \item{i, ...}{indices specifying elements to extract. Indices 17 | are \code{numeric} or \code{character} vectors or a \code{list} containing both.} 18 | } 19 | \description{ 20 | Extract parts of a \code{Container} object similar 21 | to R's base extract operators on lists. 22 | } 23 | \details{ 24 | \code{[} selects multiple values. The indices can be \code{numeric} or 25 | \code{character} or both. They can be passed as a \code{vector} or \code{list} or, 26 | for convenience, just as a comma-separated sequence (see Examples). 27 | Non-existing indices are ignored. 28 | 29 | \code{[[} selects a single value using a \code{numeric} or \code{character} index. 30 | } 31 | \examples{ 32 | co = container(a = 1, b = 2, c = 3, d = 4) 33 | co[1:2] 34 | co[1, 4] 35 | co["d", 2] 36 | co[list("d", 2)] 37 | co[0:10] 38 | 39 | co = container(a = 1, b = 2) 40 | co[[1]] 41 | co[["a"]] 42 | co[["x"]] 43 | } 44 | -------------------------------------------------------------------------------- /man/OpsLogic.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Ops-logic.R 3 | \name{OpsLogic} 4 | \alias{OpsLogic} 5 | \alias{&.Dict} 6 | \alias{|.Dict} 7 | \alias{&.Set} 8 | \alias{|.Set} 9 | \title{Logic Operators} 10 | \usage{ 11 | \method{&}{Dict}(x, y) 12 | 13 | \method{|}{Dict}(x, y) 14 | 15 | \method{&}{Set}(x, y) 16 | 17 | \method{|}{Set}(x, y) 18 | } 19 | \arguments{ 20 | \item{x, y}{Depending on the operator at least one must be of class 21 | \code{\link[=Container]{Container()}} or the respective derived class and the other at least be 22 | coercible to the respective class.} 23 | } 24 | \description{ 25 | Binary logic operators for \code{\link[=Container]{Container()}} objects and 26 | derived classes. 27 | } 28 | \examples{ 29 | d1 = dict(a = 1, b = 2) 30 | d2 = dict(a = 10, x = 4) 31 | d1 & d2 # {a = 1} 32 | 33 | } 34 | -------------------------------------------------------------------------------- /man/OpsReplace.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/Ops-replace.R 3 | \name{OpsReplace} 4 | \alias{OpsReplace} 5 | \alias{[<-.Container} 6 | \alias{[[<-.Container} 7 | \alias{$<-.Container} 8 | \title{Replace Parts of a Container} 9 | \usage{ 10 | \method{[}{Container}(x, i) <- value 11 | 12 | \method{[[}{Container}(x, i) <- value 13 | 14 | \method{$}{Container}(x, name) <- value 15 | } 16 | \arguments{ 17 | \item{x}{\code{Container} object in which to replace elements.} 18 | 19 | \item{i}{indices specifying elements to replace. Indices 20 | are \code{numeric} or \code{character} vectors or a \code{list} containing both.} 21 | 22 | \item{value}{the replacing value of \code{ANY} type} 23 | 24 | \item{name}{\code{character} string (possibly backtick quoted)} 25 | } 26 | \description{ 27 | Replace parts of a \code{Container} object similar 28 | to R's base replace operators on lists. 29 | } 30 | \details{ 31 | \verb{[<-} replaces multiple values. The indices can be \code{numeric} or 32 | \code{character} or both. They can be passed as a \code{vector} or \code{list}. Values can 33 | be added by 'replacing' at new indices, which only works for \code{character} 34 | indices. 35 | 36 | \verb{[[<-} replaces a single value at a given \code{numeric} or \code{character} index. 37 | Instead of an index, it is also possible to replace certain elements by 38 | passing the element in curly braces (see Examples), that is, the object is 39 | searched for the element and then the element is replaced by the value. 40 | 41 | \verb{$<-} replaces a single element at a given name. 42 | } 43 | \examples{ 44 | co = container(a = 1, b = "bar") 45 | (co[1:2] <- 1:2) 46 | 47 | try({ 48 | co[3] <- 3 # index out of range 49 | }) 50 | (co[list(1, "b")] <- 3:4) # mixed numeric/character index 51 | 52 | co = container(a = 1, b = 2) 53 | co[[1]] <- 9 54 | co[["b"]] <- 8 55 | co[["x"]] <- 7 56 | co$z <- 99 57 | print(co) 58 | 59 | # Replace 8 by 0 60 | co[[{8}]] <- 0 61 | print(co) 62 | 63 | 64 | co = container(a = 1, b = "bar") 65 | co$f <- 3 66 | co$b <- 2 67 | co 68 | 69 | } 70 | -------------------------------------------------------------------------------- /man/add.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add.R 3 | \name{add} 4 | \alias{add} 5 | \alias{ref_add} 6 | \alias{add.Container} 7 | \alias{ref_add.Container} 8 | \alias{add.Dict} 9 | \alias{ref_add.Dict} 10 | \alias{add.dict.table} 11 | \alias{ref_add.dict.table} 12 | \title{Add Elements to Containers} 13 | \usage{ 14 | add(.x, ...) 15 | 16 | ref_add(.x, ...) 17 | 18 | \method{add}{Container}(.x, ...) 19 | 20 | \method{ref_add}{Container}(.x, ...) 21 | 22 | \method{add}{Dict}(.x, ...) 23 | 24 | \method{ref_add}{Dict}(.x, ...) 25 | 26 | \method{add}{dict.table}(.x, ...) 27 | 28 | \method{ref_add}{dict.table}(.x, ...) 29 | } 30 | \arguments{ 31 | \item{.x}{an \code{R} object of the respective class.} 32 | 33 | \item{...}{elements to be added.} 34 | } 35 | \value{ 36 | For \link{Container}, an object of class \link{Container} (or one of the 37 | respective derived classes). 38 | 39 | For \link{dict.table} an object of class 40 | \link{dict.table}. 41 | } 42 | \description{ 43 | Add elements to container-like objects. 44 | } 45 | \note{ 46 | While \link{add} uses copy semantics \link{ref_add} works by reference. 47 | 48 | If \code{.x} is a \link{Container}, \link{Set} or \link{Deque} object, the elements being added 49 | can (but must not) be named. 50 | 51 | If \code{.x} is a \link{Dict} or \link{dict.table} object, 52 | all elements \emph{must} be of the form \code{key = value}. 53 | If one of the keys already exists, an error is given. 54 | } 55 | \examples{ 56 | 57 | co = container(1) 58 | add(co, 1, b = 2, c = container(1:3)) 59 | 60 | s = setnew(1) 61 | add(s, 1, 1, b = 2, "1", co = container(1, 1)) 62 | 63 | d = dict(a = 1) 64 | add(d, b = 2, co = container(1:3)) 65 | 66 | try(add(d, a = 7:9)) # key 'a' already in Dict 67 | 68 | dit = dict.table(a = 1:3) 69 | add(dit, b = 3:1, d = 4:6) 70 | 71 | try(add(dit, a = 7:9)) # column 'a' already exists 72 | 73 | dit = dict.table(a = 1:3) 74 | add(dit, b = 3:1, d = 4:6) 75 | 76 | try(add(dit, a = 7:9)) # column 'a' already exists 77 | } 78 | -------------------------------------------------------------------------------- /man/addleft.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/addleft.R 3 | \name{addleft} 4 | \alias{addleft} 5 | \alias{ref_addleft} 6 | \alias{addleft.Deque} 7 | \alias{ref_addleft.Deque} 8 | \title{Add Elements to the Left of Deques} 9 | \usage{ 10 | addleft(.x, ...) 11 | 12 | ref_addleft(.x, ...) 13 | 14 | \method{addleft}{Deque}(.x, ...) 15 | 16 | \method{ref_addleft}{Deque}(.x, ...) 17 | } 18 | \arguments{ 19 | \item{.x}{a \verb{[Deque]} object} 20 | 21 | \item{...}{elements to be added.} 22 | } 23 | \value{ 24 | For \link{Deque}, an object of class \link{Deque} with the elements being 25 | added to the left of \code{.x}. 26 | } 27 | \description{ 28 | Add elements to left side of \link{Deque} objects. 29 | } 30 | \note{ 31 | While \link{addleft} uses copy semantics \link{ref_addleft} work by reference. 32 | } 33 | \examples{ 34 | d = deque(0) 35 | add(d, a = 1, b = 2) # |0, a = 1, b = 2| 36 | addleft(d, a = 1, b = 2) # |b = 2, a = 1, 0| 37 | } 38 | -------------------------------------------------------------------------------- /man/at.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/at.R 3 | \name{at} 4 | \alias{at} 5 | \alias{at.Container} 6 | \alias{at.dict.table} 7 | \title{Extract Elements Safely} 8 | \usage{ 9 | at(.x, ...) 10 | 11 | \method{at}{Container}(.x, ...) 12 | 13 | \method{at}{dict.table}(.x, ...) 14 | } 15 | \arguments{ 16 | \item{.x}{an \code{R} object of the respective class.} 17 | 18 | \item{...}{indices of elements to be extracted} 19 | } 20 | \value{ 21 | For \code{Container}, returns the values at the given indidces. 22 | 23 | For \code{dict.table}, returns the columns at the given indices. 24 | } 25 | \description{ 26 | Extract parts of a Container at given indices. If an index is invalid, an 27 | error is signaled. If given as a string, the element matching the 28 | name is returned. If there are two or more identical names, the value of the 29 | first match (i.e. \emph{leftmost} element) is returned. Indices can be letters or 30 | numbers, or both at the same time. 31 | } 32 | \examples{ 33 | 34 | # Container 35 | co = container(a = 1, 2, b = 3, 4) 36 | at(co, 1:3) 37 | at(co, "a", "b", 2) 38 | try(at(co, "x")) # index 'x' not found 39 | try(at(co, 1:10)) # index 5 exceeds length of Container 40 | # Dict 41 | d = dict(a = 1, b = 3) 42 | at(d, 1:2) 43 | at(d, "a", 2) 44 | try(at(d, "x")) # index 'x' not found 45 | try(at(d, 1:3)) # index 5 exceeds length of Dict 46 | 47 | # dict.table 48 | dit = dict.table(a = 1:3, b = 4:6) 49 | at(dit, "a") 50 | at(dit, 2) 51 | at(dit, "a", 2) 52 | try(at(dit, "x")) # index 'x' not found 53 | try(at(dit, 1:3)) # index 3 exceeds length of dict.table 54 | } 55 | \seealso{ 56 | \code{\link[=peek_at]{peek_at()}} for less strict extraction 57 | } 58 | -------------------------------------------------------------------------------- /man/at2.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/at2.R 3 | \name{at2} 4 | \alias{at2} 5 | \alias{at2.Container} 6 | \alias{at2.dict.table} 7 | \title{Extract Single Elements Safely} 8 | \usage{ 9 | at2(x, ...) 10 | 11 | \method{at2}{Container}(x, index, ...) 12 | 13 | \method{at2}{dict.table}(x, index, ...) 14 | } 15 | \arguments{ 16 | \item{x}{an \code{R} object of the respective class.} 17 | 18 | \item{...}{other arguments passed to or from methods.} 19 | 20 | \item{index}{\code{character} name or \code{numeric} position of the sought value.} 21 | } 22 | \value{ 23 | For \code{Container}, returns the value at the given index. 24 | 25 | For \code{dict.table}, returns the column at the given \code{index} or signals 26 | an error if not found. 27 | } 28 | \description{ 29 | Extracts the value of a Container at the given index. If the index is 30 | invalid, an error is signaled. If given as a string, the element matching the 31 | name is returned. If there are two or more identical names, the value of the 32 | first match (i.e. \emph{leftmost} element) is returned. 33 | Extract value at index. If index is invalid or not found, an error is 34 | signaled. If given as a string, the element matching the name is returned. 35 | If there are two or more identical names, the value of the first match (i.e. 36 | \emph{leftmost} element) is returned. 37 | } 38 | \examples{ 39 | 40 | # Container 41 | co = container(a = 1, 2, b = 3, 4) 42 | at2(co, 1) 43 | at2(co, "a") 44 | at2(co, 2) 45 | try(at2(co, "x")) # index 'x' not found 46 | try(at2(co, 5)) # index 5 exceeds length of Container 47 | 48 | # Dict 49 | d = dict(a = 1, b = 3) 50 | at2(d, 1) 51 | at2(d, "a") 52 | at2(d, 2) 53 | try(at2(d, "x")) # index 'x' not found 54 | try(at2(d, 5)) # index 5 exceeds length of Dict 55 | 56 | # dict.table 57 | dit = dict.table(a = 1:3, b = 4:6) 58 | at2(dit, 1) 59 | at2(dit, "a") 60 | at2(dit, 2) 61 | try(at2(dit, "x")) # index 'x' not found 62 | try(at2(dit, 5)) # index 5 exceeds length of dict.table 63 | } 64 | \seealso{ 65 | \code{\link[=peek_at2]{peek_at2()}} for less strict extraction 66 | } 67 | -------------------------------------------------------------------------------- /man/clear.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/clear.R 3 | \name{clear} 4 | \alias{clear} 5 | \alias{ref_clear} 6 | \alias{clear.Container} 7 | \alias{ref_clear.Container} 8 | \alias{clear.dict.table} 9 | \alias{ref_clear.dict.table} 10 | \title{Clear a Container} 11 | \usage{ 12 | clear(x) 13 | 14 | ref_clear(x) 15 | 16 | \method{clear}{Container}(x) 17 | 18 | \method{ref_clear}{Container}(x) 19 | 20 | \method{clear}{dict.table}(x) 21 | 22 | \method{ref_clear}{dict.table}(x) 23 | } 24 | \arguments{ 25 | \item{x}{any \code{R} object.} 26 | } 27 | \value{ 28 | For \link{Container}, an object of class \link{Container} (or one of the 29 | respective derived classes). 30 | 31 | For \link{dict.table} an object of class 32 | \link{dict.table}. 33 | } 34 | \description{ 35 | Removes all elements from the container object. 36 | } 37 | \examples{ 38 | 39 | co = container(1, 2, mean) 40 | clear(co) 41 | co 42 | ref_clear(co) 43 | co 44 | 45 | dit = dict.table(a = 1, b = 2) 46 | clear(dit) 47 | dit # original was not touched 48 | ref_clear(dit) 49 | dit # original was cleared 50 | } 51 | -------------------------------------------------------------------------------- /man/clone.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/clone.R 3 | \name{clone} 4 | \alias{clone} 5 | \alias{clone.Container} 6 | \alias{clone.dict.table} 7 | \title{Clone an Object} 8 | \usage{ 9 | clone(x) 10 | 11 | \method{clone}{Container}(x) 12 | 13 | \method{clone}{dict.table}(x) 14 | } 15 | \arguments{ 16 | \item{x}{any \code{R} object.} 17 | } 18 | \value{ 19 | A copy of the object. 20 | } 21 | \description{ 22 | Creates a copy of the object. 23 | } 24 | \examples{ 25 | 26 | co = container(1, 2, 3) 27 | co2 = clone(co) 28 | co == co2 29 | 30 | d = dict.table(a = 1:2, b = 3:4) 31 | d2 = clone(d) 32 | ref_clear(d) 33 | print(d2) 34 | } 35 | -------------------------------------------------------------------------------- /man/container_options.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/options.R 3 | \name{container_options} 4 | \alias{container_options} 5 | \alias{getContainerOption} 6 | \title{Set Container Package Options} 7 | \usage{ 8 | container_options(..., .reset = FALSE) 9 | 10 | getContainerOption(x, default = NULL) 11 | } 12 | \arguments{ 13 | \item{...}{any options can be defined, using name = value.} 14 | 15 | \item{.reset}{\code{logical} if \code{TRUE}, the options are reset to their default and 16 | returned.} 17 | 18 | \item{x}{a character string holding an option name.} 19 | 20 | \item{default}{if the specified option is not set in the options list, this 21 | value is returned.} 22 | } 23 | \value{ 24 | \itemize{ 25 | \item \code{container_options()} returns a list of all set options sorted by name. 26 | \item \code{container_options(name)}, a list of length one containing the set value, 27 | or \code{NULL} if it is unset. Can also be multiple names (see Examples). 28 | \item \code{container_options(key = value)} sets the option with name \code{key} to \code{value} 29 | and returns the previous options invisibly. 30 | } 31 | } 32 | \description{ 33 | Set Container Package Options 34 | } 35 | \section{Container Options}{ 36 | 37 | \itemize{ 38 | \item \code{compare} (default = \code{all.equal}) 39 | \item \code{useDots} (default = \code{TRUE}) whether to abbreviate long container 40 | elements with \code{...} when exceeding \code{vec.len} (see below). If \code{FALSE}, they 41 | are abbreviated as \verb{<>}. 42 | \item \code{vec.len} (default = 4) the length limit at which container vectors are 43 | abbreviated. 44 | } 45 | } 46 | 47 | \examples{ 48 | co = container(1L, 1:10, as.list(1:5)) 49 | co 50 | 51 | container_options(useDots = FALSE) 52 | co 53 | 54 | container_options(useDots = TRUE, vec.len = 6) 55 | co 56 | 57 | has(co, 1.0) 58 | 59 | container_options(compare = "identical") 60 | 61 | has(co, 1.0) # still uses 'all.equal' 62 | 63 | co2 = container(1L) 64 | has(co2, 1.0) 65 | has(co2, 1L) 66 | 67 | container_options() 68 | container_options(.reset = TRUE) 69 | } 70 | -------------------------------------------------------------------------------- /man/count.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/count.R 3 | \name{count} 4 | \alias{count} 5 | \alias{count.Container} 6 | \alias{count.Set} 7 | \title{Count Elements} 8 | \usage{ 9 | count(x, elem) 10 | 11 | \method{count}{Container}(x, elem) 12 | 13 | \method{count}{Set}(x, elem) 14 | } 15 | \arguments{ 16 | \item{x}{any \code{R} object.} 17 | 18 | \item{elem}{element to counted.} 19 | } 20 | \value{ 21 | \code{integer} number of how many times \code{elem} occurs in the object. 22 | } 23 | \description{ 24 | Count the number of occurences of some element. 25 | } 26 | \examples{ 27 | 28 | co = container("a", "b", "a", mean, mean) 29 | count(co, "a") 30 | count(co, mean) 31 | count(co, "c") 32 | } 33 | -------------------------------------------------------------------------------- /man/delete.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/delete.R 3 | \name{delete} 4 | \alias{delete} 5 | \alias{ref_delete} 6 | \alias{delete.Container} 7 | \alias{ref_delete.Container} 8 | \title{Delete Container Elements Safely} 9 | \usage{ 10 | delete(.x, ...) 11 | 12 | ref_delete(.x, ...) 13 | 14 | \method{delete}{Container}(.x, ...) 15 | 16 | \method{ref_delete}{Container}(.x, ...) 17 | } 18 | \arguments{ 19 | \item{.x}{any \code{R} object.} 20 | 21 | \item{...}{elements to be deleted.} 22 | } 23 | \value{ 24 | For \code{Container}, an object of class \code{Container} (or one of the 25 | respective derived classes). 26 | } 27 | \description{ 28 | Search and remove elements from an object. If the element is not found, 29 | an error is signaled. 30 | } 31 | \examples{ 32 | 33 | s = setnew("a", 1:3, iris) 34 | print(s) 35 | delete(s, 1:3, "a") 36 | delete(s, iris) 37 | try({ 38 | delete(s, "b") # "b" is not in Set 39 | }) 40 | } 41 | -------------------------------------------------------------------------------- /man/delete_at.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/delete_at.R 3 | \name{delete_at} 4 | \alias{delete_at} 5 | \alias{ref_delete_at} 6 | \alias{delete_at.Container} 7 | \alias{ref_delete_at.Container} 8 | \alias{delete_at.dict.table} 9 | \alias{ref_delete_at.dict.table} 10 | \title{Delete Elements at Indices Safely} 11 | \usage{ 12 | delete_at(.x, ...) 13 | 14 | ref_delete_at(.x, ...) 15 | 16 | \method{delete_at}{Container}(.x, ...) 17 | 18 | \method{ref_delete_at}{Container}(.x, ...) 19 | 20 | \method{delete_at}{dict.table}(.x, ...) 21 | 22 | \method{ref_delete_at}{dict.table}(.x, ...) 23 | } 24 | \arguments{ 25 | \item{.x}{any \code{R} object.} 26 | 27 | \item{...}{indices at which values are to be deleted.} 28 | } 29 | \value{ 30 | For \code{Container}, an object of class \code{Container} (or one of the 31 | respective derived classes). 32 | 33 | For \code{dict.table}, an object of class \code{dict.table}. 34 | } 35 | \description{ 36 | Search and remove values at given indices, which can be numeric or character 37 | or both. If any given index is invalid, an error is signaled. Indices can be 38 | numbers or names or both. 39 | } 40 | \examples{ 41 | 42 | co = container(a = 1, b = 2, 3) 43 | delete_at(co, "a", "b") # [3] 44 | delete_at(co, 1:2) # [3] 45 | delete_at(co, "a", 3) # [b = 2] 46 | try({ 47 | delete_at(co, 4) # index out of range 48 | delete_at(co, "x") # names(s) not found: 'x' 49 | }) 50 | 51 | dit = as.dict.table(head(sleep)) 52 | dit 53 | delete_at(dit, "ID") 54 | delete_at(dit, "ID", 1) 55 | try({ 56 | delete_at(dit, "foo") # Column 'foo' not in dict.table 57 | }) 58 | } 59 | -------------------------------------------------------------------------------- /man/deprecated.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/container-deprecated.R 3 | \name{deprecated} 4 | \alias{deprecated} 5 | \alias{empty} 6 | \alias{empty.Container} 7 | \alias{size} 8 | \alias{size.Container} 9 | \alias{sortkey} 10 | \alias{sortkey.Dict} 11 | \alias{values} 12 | \alias{values.Container} 13 | \alias{values.dict.table} 14 | \alias{keys} 15 | \title{Deprecated Functions} 16 | \usage{ 17 | empty(x) 18 | 19 | \method{empty}{Container}(x) 20 | 21 | size(x) 22 | 23 | \method{size}{Container}(x) 24 | 25 | sortkey(x, decr = FALSE) 26 | 27 | \method{sortkey}{Dict}(x, decr = FALSE) 28 | 29 | values(x) 30 | 31 | \method{values}{Container}(x) 32 | 33 | \method{values}{dict.table}(x) 34 | 35 | keys(x) 36 | } 37 | \arguments{ 38 | \item{x}{any \code{R} object.} 39 | 40 | \item{decr}{\code{logical} sort decreasingly?} 41 | } 42 | \description{ 43 | These functions are provided for backwards-compatibility and 44 | may be defunct as soon as the next release. 45 | } 46 | \details{ 47 | \itemize{ 48 | \item \code{\link[=empty]{empty()}} \code{\link[=is_empty]{is_empty()}} instead 49 | \item \code{set()} \code{\link[=setnew]{setnew()}} instead 50 | \item \code{\link[=size]{size()}} use \code{\link[=length]{length()}} instead 51 | \item \code{\link[=sortkey]{sortkey()}} keys of \link{Dict} objects are now always sorted 52 | \item \code{\link[=remove]{remove()}} use \code{\link[=delete]{delete()}} instead 53 | \item \code{\link[=type]{type()}} not of use anymore 54 | \item \code{\link[=values]{values()}} use \code{\link[=as.list]{as.list()}} instead 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /man/discard.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discard.R 3 | \name{discard} 4 | \alias{discard} 5 | \alias{ref_discard} 6 | \alias{discard.Container} 7 | \alias{ref_discard.Container} 8 | \title{Discard Container Elements} 9 | \usage{ 10 | discard(.x, ...) 11 | 12 | ref_discard(.x, ...) 13 | 14 | \method{discard}{Container}(.x, ...) 15 | 16 | \method{ref_discard}{Container}(.x, ...) 17 | } 18 | \arguments{ 19 | \item{.x}{any \code{R} object.} 20 | 21 | \item{...}{elements to be discarded.} 22 | } 23 | \value{ 24 | For \code{Container}, an object of class \code{Container} (or one of the 25 | respective derived classes). 26 | } 27 | \description{ 28 | Search and remove an element from an object. If the element is not found, 29 | ignore the attempt. 30 | } 31 | \examples{ 32 | 33 | s = setnew("a", num = 1:3, data = iris) 34 | print(s) 35 | discard(s, 1:3, "a") 36 | discard(s, iris) 37 | discard(s, "b") # ignored 38 | } 39 | -------------------------------------------------------------------------------- /man/discard_at.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/discard_at.R 3 | \name{discard_at} 4 | \alias{discard_at} 5 | \alias{ref_discard_at} 6 | \alias{discard_at.Container} 7 | \alias{ref_discard_at.Container} 8 | \alias{discard_at.dict.table} 9 | \alias{ref_discard_at.dict.table} 10 | \title{Discard Elements at Indices} 11 | \usage{ 12 | discard_at(.x, ...) 13 | 14 | ref_discard_at(.x, ...) 15 | 16 | \method{discard_at}{Container}(.x, ...) 17 | 18 | \method{ref_discard_at}{Container}(.x, ...) 19 | 20 | \method{discard_at}{dict.table}(.x, ...) 21 | 22 | \method{ref_discard_at}{dict.table}(.x, ...) 23 | } 24 | \arguments{ 25 | \item{.x}{any \code{R} object.} 26 | 27 | \item{...}{indices at which values are to be discarded.} 28 | } 29 | \value{ 30 | For \code{Container}, an object of class \code{Container} (or one of the 31 | respective derived classes). 32 | 33 | For \code{dict.table}, an object of class \code{dict.table}. 34 | } 35 | \description{ 36 | Search and remove values at given indices, which can be numeric or character 37 | or both. Invalid indices are ignored. 38 | } 39 | \examples{ 40 | 41 | co = container(a = 1, b = 2, 3) 42 | discard_at(co, "a", "b") # [3] 43 | discard_at(co, 1:2) # [3] 44 | discard_at(co, "a", 3) # [b = 2] 45 | discard_at(co, "x") # ignored 46 | 47 | dit = as.dict.table(head(sleep)) 48 | discard_at(dit, "ID") 49 | discard_at(dit, "ID", 1) 50 | discard_at(dit, "foo") # ignored 51 | } 52 | -------------------------------------------------------------------------------- /man/figures/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/man/figures/logo.png -------------------------------------------------------------------------------- /man/has.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/has.R 3 | \name{has} 4 | \alias{has} 5 | \alias{has.Container} 6 | \alias{has.dict.table} 7 | \title{Check for Element} 8 | \usage{ 9 | has(x, ...) 10 | 11 | \method{has}{Container}(x, elem, ...) 12 | 13 | \method{has}{dict.table}(x, column, ...) 14 | } 15 | \arguments{ 16 | \item{x}{any \code{R} object.} 17 | 18 | \item{...}{additional arguments to be passed to or from methods.} 19 | 20 | \item{elem}{some element to be found.} 21 | 22 | \item{column}{vector of values with the same length as the number of rows 23 | of the \code{dict.table}.} 24 | } 25 | \value{ 26 | \code{TRUE} if element is in \code{x} and otherwise \code{FALSE}. 27 | 28 | For \code{dict.table}, \code{TRUE} if column exists in \code{x} otherwise \code{FALSE}. 29 | } 30 | \description{ 31 | Check for Element 32 | } 33 | \examples{ 34 | 35 | co = container(1, 2, mean) 36 | has(co, 1) # TRUE 37 | has(co, mean) # TRUE 38 | has(co, 1:2) # FALSE 39 | 40 | dit = dict.table(a = 1:3, b = as.list(4:6)) 41 | has(dit, 1:3) # TRUE 42 | has(dit, 4:6) # FALSE 43 | has(dit, as.list(4:6)) # TRUE 44 | } 45 | \seealso{ 46 | \code{\link[=has_name]{has_name()}} 47 | } 48 | -------------------------------------------------------------------------------- /man/has_name.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/has_name.R 3 | \name{has_name} 4 | \alias{has_name} 5 | \alias{has_name.Container} 6 | \alias{has_name.dict.table} 7 | \title{Check for Name} 8 | \usage{ 9 | has_name(x, name) 10 | 11 | \method{has_name}{Container}(x, name) 12 | 13 | \method{has_name}{dict.table}(x, name) 14 | } 15 | \arguments{ 16 | \item{x}{any \code{R} object.} 17 | 18 | \item{name}{\code{character} the name to be found.} 19 | } 20 | \value{ 21 | \code{TRUE} if name is in \code{x} and otherwise \code{FALSE}. 22 | 23 | For \code{dict.table} \code{TRUE} if the dict.table objects has the given 24 | column name, otherwise \code{FALSE}. 25 | } 26 | \description{ 27 | Check for Name 28 | } 29 | \examples{ 30 | 31 | co = container(a = 1, 2, f = mean) 32 | has_name(co, "a") # TRUE 33 | has_name(co, "f") # TRUE 34 | has_name(co, "2") # FALSE 35 | 36 | dit = dict.table(a = 1:2, b = 3:4) 37 | has_name(dit, "a") # TRUE 38 | has_name(dit, "x") # FALSE 39 | } 40 | \seealso{ 41 | \code{\link[=has]{has()}} 42 | } 43 | -------------------------------------------------------------------------------- /man/is_empty.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/is_empty.R 3 | \name{is_empty} 4 | \alias{is_empty} 5 | \alias{is_empty.Container} 6 | \alias{is_empty.dict.table} 7 | \title{Check if Object is Empty} 8 | \usage{ 9 | is_empty(x) 10 | 11 | \method{is_empty}{Container}(x) 12 | 13 | \method{is_empty}{dict.table}(x) 14 | } 15 | \arguments{ 16 | \item{x}{any \code{R} object.} 17 | } 18 | \value{ 19 | \code{TRUE} if object is empty otherwise \code{FALSE}. 20 | } 21 | \description{ 22 | Check if Object is Empty 23 | } 24 | \examples{ 25 | 26 | co = container(1, 2) 27 | is_empty(co) 28 | is_empty(clear(co)) 29 | 30 | d = dict.table(a = 1:4, b = 4:1) 31 | is_empty(d) 32 | is_empty(clear(d)) 33 | } 34 | -------------------------------------------------------------------------------- /man/peek.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/peek.R 3 | \name{peek} 4 | \alias{peek} 5 | \alias{peekleft} 6 | \alias{peek.Deque} 7 | \alias{peekleft.Deque} 8 | \title{Peek at Left or Right of a Deque} 9 | \usage{ 10 | peekleft(x, default = NULL) 11 | 12 | peek(x, default = NULL) 13 | 14 | \method{peek}{Deque}(x, default = NULL) 15 | 16 | \method{peekleft}{Deque}(x, default = NULL) 17 | } 18 | \arguments{ 19 | \item{x}{a \code{Deque} object.} 20 | 21 | \item{default}{value to be returned if peeked value does not exist.} 22 | } 23 | \value{ 24 | The first (\code{peekleft}) or last (\code{peek}) element. 25 | } 26 | \description{ 27 | Try to access first or last element and return some default value if not found. 28 | In contrast to \verb{[at2()]}, this function provides a less stricter element 29 | access, that is, it remains valid even if peeked elements don't exist. 30 | } 31 | \details{ 32 | \code{peek} peek at last element of a \code{Deque}. 33 | 34 | \code{peekleft} peek at first element of a \code{Deque}. 35 | } 36 | \examples{ 37 | # Deque 38 | d = deque(1, 2, 3) 39 | peek(d) 40 | peekleft(d) 41 | peek(deque()) 42 | peek(deque(), default = 0) 43 | peekleft(deque(), default = 0) 44 | } 45 | \seealso{ 46 | \code{\link[=at2]{at2()}} for strict element extraction 47 | } 48 | -------------------------------------------------------------------------------- /man/peek_at.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/peek_at.R 3 | \name{peek_at} 4 | \alias{peek_at} 5 | \alias{peek_at.Container} 6 | \alias{peek_at.dict.table} 7 | \title{Peek at Indices} 8 | \usage{ 9 | peek_at(.x, ...) 10 | 11 | \method{peek_at}{Container}(.x, ..., .default = NULL) 12 | 13 | \method{peek_at}{dict.table}(.x, ..., .default = NULL) 14 | } 15 | \arguments{ 16 | \item{.x}{an \code{R} object of the respective class.} 17 | 18 | \item{...}{indices of elements to be extracted} 19 | 20 | \item{.default}{value to be returned if peeked value does not exist.} 21 | } 22 | \value{ 23 | For \code{Container}, returns the value at the given indices or (if not 24 | found) the given default value. 25 | 26 | For \code{dict.table}, returns the columns at the given indices or (if not 27 | found) columns with the given default value. 28 | } 29 | \description{ 30 | Try to access elements and return default values if not found. 31 | In contrast to \verb{[at()]}, this function provides a less stricter element 32 | access, that is, it remains valid even if elements don't exist. 33 | } 34 | \details{ 35 | \code{peek_at} tries to access specific values. 36 | } 37 | \examples{ 38 | 39 | # Container 40 | co = container(a = 1, 2, b = 3, 4) 41 | peek_at(co, 1) 42 | peek_at(co, "a") 43 | peek_at(co, "x") 44 | peek_at(co, "x", .default = 0) 45 | peek_at(co, "a", "x", 2, 9, .default = -1) 46 | 47 | # Dict 48 | d = dict(a = 1, b = 1:3) 49 | peek_at(d, "b") 50 | peek_at(d, "x") 51 | peek_at(d, "x", .default = 4:7) 52 | 53 | # dict.table 54 | dit = dict.table(a = 1:3, b = 4:6) 55 | peek_at(dit, "a") 56 | peek_at(dit, 1) 57 | peek_at(dit, 3) 58 | peek_at(dit, "x") 59 | peek_at(dit, "x", .default = 0) 60 | peek_at(dit, "a", "x", .default = 0) 61 | } 62 | \seealso{ 63 | \code{\link[=at]{at()}} for strict element extraction 64 | } 65 | -------------------------------------------------------------------------------- /man/peek_at2.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/peek_at2.R 3 | \name{peek_at2} 4 | \alias{peek_at2} 5 | \alias{peek_at2.Container} 6 | \alias{peek_at2.dict.table} 7 | \title{Peek at Single Index} 8 | \usage{ 9 | peek_at2(x, index, default = NULL) 10 | 11 | \method{peek_at2}{Container}(x, index, default = NULL) 12 | 13 | \method{peek_at2}{dict.table}(x, index, default = NULL) 14 | } 15 | \arguments{ 16 | \item{x}{an \code{R} object of the respective class.} 17 | 18 | \item{index}{\code{character} name or \code{numeric} position of the sought value.} 19 | 20 | \item{default}{value to be returned if peeked value does not exist.} 21 | } 22 | \value{ 23 | For \code{Container}, returns the value at the given index or (if not 24 | found) the given default value. 25 | 26 | For \code{dict.table}, returns the column named \code{index} if it exist 27 | otherwise the given \code{default} value. If the default length does not match 28 | the number of rows, it is recycled accordingly and a warning is given, 29 | unless the default value has a length of 1, in which case recycling is 30 | done silently. 31 | } 32 | \description{ 33 | Try to access element and return some default value if not found. 34 | In contrast to \verb{[at2()]}, this function provides a less stricter element 35 | access, that is, it remains valid even if peeked elements don't exist. 36 | } 37 | \examples{ 38 | 39 | # Container 40 | co = container(a = 1, 2, b = 3, 4) 41 | peek_at2(co, 1) 42 | peek_at2(co, "a") 43 | peek_at2(co, "x") 44 | peek_at2(co, "x", default = 0) 45 | 46 | # Dict 47 | d = dict(a = 1, b = 1:3) 48 | peek_at2(d, "b") 49 | peek_at2(d, "x") 50 | peek_at2(d, "x", default = 4:7) 51 | 52 | # dict.table 53 | dit = dict.table(a = 1:3, b = 4:6) 54 | peek_at2(dit, "a") 55 | peek_at2(dit, 1) 56 | peek_at2(dit, 3) 57 | peek_at2(dit, 3, default = 9) 58 | peek_at2(dit, "x") 59 | peek_at2(dit, "x", default = 0) 60 | } 61 | \seealso{ 62 | \code{\link[=at2]{at2()}} for strict element extraction 63 | } 64 | -------------------------------------------------------------------------------- /man/pop.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/pop.R 3 | \name{pop} 4 | \alias{pop} 5 | \alias{ref_pop} 6 | \alias{ref_popleft} 7 | \alias{ref_pop.Deque} 8 | \alias{ref_popleft.Deque} 9 | \alias{ref_pop.Container} 10 | \alias{ref_pop.dict.table} 11 | \title{Get and Remove Element} 12 | \usage{ 13 | ref_pop(.x, ...) 14 | 15 | ref_popleft(.x, ...) 16 | 17 | \method{ref_pop}{Deque}(.x, ...) 18 | 19 | \method{ref_popleft}{Deque}(.x, ...) 20 | 21 | \method{ref_pop}{Container}(.x, index, ...) 22 | 23 | \method{ref_pop}{dict.table}(.x, index, ...) 24 | } 25 | \arguments{ 26 | \item{.x}{any \code{R} object.} 27 | 28 | \item{...}{additional arguments to be passed to or from methods.} 29 | 30 | \item{index}{\code{character} name or \code{numeric} position of value to be popped} 31 | } 32 | \value{ 33 | For \code{Deque} the first (\code{ref_popleft}) or last (\code{ref_pop}) element of 34 | the deque after it was removed. 35 | 36 | For \code{Container} the value at the given index after it was removed from 37 | the \code{Container} object. If \code{index} is not found, an error is raised. 38 | 39 | For \code{dict.table}, returns the column at the given \code{index} after it was 40 | removed from the \code{dict.table}. If column does not exist, an error is raised. 41 | } 42 | \description{ 43 | Search and return an element and remove it afterwards from the object. 44 | If the element is not found, signal an error. 45 | } 46 | \details{ 47 | All functions work by reference, that is, the original object is altered. 48 | \code{ref_pop(.x)} tries to access specific values. 49 | 50 | \code{ref_popleft(.x)} pops first element of a \code{Deque}. 51 | } 52 | \examples{ 53 | # Deque 54 | d = deque(1, 2, 3) 55 | ref_pop(d) 56 | ref_popleft(d) 57 | 58 | try({ 59 | ref_pop(deque()) # pop at empty Deque 60 | }) 61 | 62 | # Container 63 | co = container(a = 1, b = 1:3, d = "foo") 64 | ref_pop(co, "b") 65 | ref_pop(co, 1) 66 | 67 | try({ 68 | ref_pop(co, "x") # index 'x' not found 69 | }) 70 | 71 | # dict.table 72 | dit = dict.table(a = 1:3, b = 4:6) 73 | ref_pop(dit, "a") 74 | ref_pop(dit, 1) 75 | 76 | try({ 77 | ref_pop(dit, "x") # index 'x' not found 78 | }) 79 | } 80 | \seealso{ 81 | \code{\link[=peek]{peek()}} 82 | } 83 | -------------------------------------------------------------------------------- /man/rename.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rename.R 3 | \name{rename} 4 | \alias{rename} 5 | \alias{ref_rename} 6 | \alias{rename.Container} 7 | \alias{rename.dict.table} 8 | \alias{ref_rename.dict.table} 9 | \alias{rename.default} 10 | \title{Rename Elements Safely} 11 | \usage{ 12 | rename(.x, old, new) 13 | 14 | ref_rename(.x, old, new) 15 | 16 | \method{rename}{Container}(.x, old, new) 17 | 18 | \method{rename}{dict.table}(.x, old, new) 19 | 20 | \method{ref_rename}{dict.table}(.x, old, new) 21 | 22 | \method{rename}{default}(.x, old, new) 23 | } 24 | \arguments{ 25 | \item{.x}{\code{dict.table} object} 26 | 27 | \item{old}{\code{character} old name} 28 | 29 | \item{new}{\code{character} new name} 30 | } 31 | \value{ 32 | For standard \code{R} vectors renames \code{old} to \code{new} and returns the 33 | renamed vector. 34 | 35 | For \code{Container}, an object of class \code{Container} (or one of the 36 | respective derived classes). 37 | 38 | For \code{dict.table} renames key \code{old} to \code{new} in place (i.e. by 39 | reference) and invisibly returns the \code{\link[=dict.table]{dict.table()}} object. 40 | } 41 | \description{ 42 | Search for old name and replace it by new name. If either the 43 | old name does not exist or the name would result in a name-clash with an 44 | already existing name, an error is signaled. 45 | } 46 | \details{ 47 | The passed old and new names can be vectors but always must have 48 | the same length and must be unique to prevent double-renaming. 49 | 50 | \code{rename} uses copy semantics while \code{ref_rename} works by reference, 51 | that is, it renames elements in place. 52 | } 53 | \examples{ 54 | 55 | # Container 56 | co = container(a = 1, b = 2, 3) 57 | rename(co, c("a", "b"), c("a1", "y")) 58 | print(co) 59 | ref_rename(co, c("a", "b"), c("a1", "y")) 60 | print(co) 61 | 62 | # dict.table 63 | dit = dict.table(a = 1, b = 2, c = 3) 64 | rename(dit, c("a", "b"), c("a1", "y")) 65 | print(dit) 66 | ref_rename(dit, c("a", "b"), c("a1", "y")) 67 | print(dit) 68 | } 69 | -------------------------------------------------------------------------------- /man/replace.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/replace.R 3 | \name{replace} 4 | \alias{replace} 5 | \alias{ref_replace} 6 | \alias{replace.Container} 7 | \alias{ref_replace.Container} 8 | \alias{replace.Dict} 9 | \alias{ref_replace.Dict} 10 | \title{Replace Values in Containers Safely} 11 | \usage{ 12 | replace(.x, ...) 13 | 14 | ref_replace(.x, ...) 15 | 16 | \method{replace}{Container}(.x, old, new, add = FALSE, ...) 17 | 18 | \method{ref_replace}{Container}(.x, old, new, add = FALSE, ...) 19 | 20 | \method{replace}{Dict}(.x, old, new, ...) 21 | 22 | \method{ref_replace}{Dict}(.x, old, new, ...) 23 | } 24 | \arguments{ 25 | \item{.x}{any \code{R} object.} 26 | 27 | \item{...}{additional arguments to be passed to or from methods.} 28 | 29 | \item{old}{old element to be found and replaced.} 30 | 31 | \item{new}{the new element replacing the old one.} 32 | 33 | \item{add}{\code{logical} if \code{FALSE} (default) and element was not found, 34 | an error is given. In contrast, if set to \code{TRUE} the new element is added 35 | regardless of whether it is used as a replacement for an existing element or 36 | just added as a new element.} 37 | } 38 | \value{ 39 | For \code{Container}, an object of class \code{Container} (or one of the 40 | respective derived classes). 41 | 42 | For \code{Dict} an object of class \code{Dict}. 43 | } 44 | \description{ 45 | Try to find and replace elements and signal an error if not 46 | found, unless it is stated to explicitly add the element (see option \code{add}). 47 | } 48 | \details{ 49 | \code{replace} uses copy semantics while \code{ref_replace} works by reference. 50 | } 51 | \examples{ 52 | 53 | co = container("x", 9) 54 | replace(co, 9, 0) 55 | replace(co, "x", 0) 56 | try({ 57 | replace(co, "z", 0) # old element ("z") is not in Container 58 | }) 59 | replace(co, "z", 0, add = TRUE) # just add the zero without replacement 60 | 61 | 62 | d = dict(a = 1, b = "z") 63 | replace(d, 1, 1:5) 64 | replace(d, "z", "a") 65 | 66 | try({ 67 | replace(d, "a", 2) # old element ("a") is not in Dict 68 | }) 69 | } 70 | -------------------------------------------------------------------------------- /man/rev.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rev.R 3 | \name{rev} 4 | \alias{rev} 5 | \alias{ref_rev} 6 | \alias{ref_rev.Deque} 7 | \alias{rev.Deque} 8 | \title{Reverse Elements} 9 | \usage{ 10 | ref_rev(x) 11 | 12 | \method{ref_rev}{Deque}(x) 13 | 14 | \method{rev}{Deque}(x) 15 | } 16 | \arguments{ 17 | \item{x}{\code{Deque} object} 18 | } 19 | \value{ 20 | For \code{Deque}, an object of class \code{Deque} 21 | } 22 | \description{ 23 | \code{rev} provides a reversed version of its argument. 24 | } 25 | \details{ 26 | \code{rev} uses copy semantics while \code{ref_rev} works by reference, 27 | that is, it reverse all elements in place. 28 | } 29 | \examples{ 30 | 31 | d = deque(a = 1, b = 2, 3) 32 | rev(d) 33 | print(d) 34 | ref_rev(d) 35 | print(d) 36 | 37 | } 38 | \seealso{ 39 | \code{\link[base:rev]{base::rev()}} 40 | } 41 | -------------------------------------------------------------------------------- /man/rotate.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rotate.R 3 | \name{rotate} 4 | \alias{rotate} 5 | \alias{ref_rotate} 6 | \alias{rotate.Deque} 7 | \alias{ref_rotate.Deque} 8 | \title{Rotate Elements} 9 | \usage{ 10 | rotate(x, n = 1L) 11 | 12 | ref_rotate(x, n = 1L) 13 | 14 | \method{rotate}{Deque}(x, n = 1L) 15 | 16 | \method{ref_rotate}{Deque}(x, n = 1L) 17 | } 18 | \arguments{ 19 | \item{x}{any \code{R} object.} 20 | 21 | \item{n}{\code{integer} number of steps to rotate} 22 | } 23 | \value{ 24 | For \code{Deque} returns the rotated \code{\link[=Deque]{Deque()}} object. 25 | } 26 | \description{ 27 | Rotate all elements \code{n} steps to the right. If n is 28 | negative, rotate to the left. 29 | } 30 | \details{ 31 | While \code{rotate} uses copy semantics, \code{ref_rotate} works by reference, 32 | that is, rotates in place on the original object. 33 | } 34 | \examples{ 35 | d = deque(1, 2, 3, 4) 36 | rotate(d) 37 | rotate(d, n = 2) 38 | } 39 | -------------------------------------------------------------------------------- /man/unpack.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/unpack.R 3 | \name{unpack} 4 | \alias{unpack} 5 | \title{Unpack Nested Objects} 6 | \usage{ 7 | unpack(x, recursive = TRUE, use.names = TRUE) 8 | } 9 | \arguments{ 10 | \item{x}{any \code{R} object} 11 | 12 | \item{recursive}{\code{logical} descend recursively into nested objects?} 13 | 14 | \item{use.names}{\code{logical} Should names be preserved?} 15 | } 16 | \value{ 17 | a \code{list} 18 | } 19 | \description{ 20 | Similary to \code{\link[=unlist]{unlist()}} recursively unpacks any (possibly nested) structure 21 | into a flat list. In contrast to \code{\link[=unlist]{unlist()}}, \code{\link[=unpack]{unpack()}} also works with 22 | (possibly nested) \code{\link[=Container]{Container()}} objects. In principle, it works for any 23 | object that can be transformed to a list via \code{as.list}. 24 | } 25 | -------------------------------------------------------------------------------- /man/update.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/update.R 3 | \name{update} 4 | \alias{update} 5 | \alias{ref_update} 6 | \alias{update.Container} 7 | \alias{ref_update.Container} 8 | \alias{update.dict.table} 9 | \alias{ref_update.dict.table} 10 | \alias{update.list} 11 | \title{Update Object with Elements from Another Object} 12 | \usage{ 13 | ref_update(object, other, ...) 14 | 15 | \method{update}{Container}(object, other, ...) 16 | 17 | \method{ref_update}{Container}(object, other, ...) 18 | 19 | \method{update}{dict.table}(object, other, ...) 20 | 21 | \method{ref_update}{dict.table}(object, other, ...) 22 | 23 | \method{update}{list}(object, other, ...) 24 | } 25 | \arguments{ 26 | \item{object}{any \code{R} object} 27 | 28 | \item{other}{any object of the same type as \code{object}} 29 | 30 | \item{...}{additional arguments to be passed to or from methods.} 31 | } 32 | \value{ 33 | For \code{Container}, an object of class \code{Container} (or one of the 34 | respective derived classes). 35 | 36 | For \code{dict.table} an object of class \code{dict.table}. 37 | 38 | For \code{list}, an updated object of class \code{list}. 39 | } 40 | \description{ 41 | Takes an object and updates it with values from another object 42 | by replacing the values at existing names and adding values at new names of 43 | the other object. A common use case is to update parameter lists. 44 | } 45 | \details{ 46 | \code{update} uses copy semantics while \code{ref_update} works by reference, 47 | that is, updates in place. 48 | } 49 | \examples{ 50 | 51 | d1 = dict(a = 1, b = 2) 52 | d2 = dict( b = 0, c = 3) 53 | update(d1, d2) # {a = 1, b = 0, c = 3} 54 | update(d2, d1) # {a = 1, b = 2, c = 3} 55 | 56 | dit1 = dict.table(a = 1:2, b = 3:4) 57 | dit2 = dict.table( b = 5:6, c = 8:9) 58 | update(d1, d2) 59 | update(d2, d1) 60 | 61 | l1 = list(1, b = 2) 62 | l2 = list( b = 0, c = 3) 63 | update(l1, l2) 64 | update(l2, l1) 65 | } 66 | -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-120x120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/pkgdown/favicon/apple-touch-icon-120x120.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-152x152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/pkgdown/favicon/apple-touch-icon-152x152.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-180x180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/pkgdown/favicon/apple-touch-icon-180x180.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-60x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/pkgdown/favicon/apple-touch-icon-60x60.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon-76x76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/pkgdown/favicon/apple-touch-icon-76x76.png -------------------------------------------------------------------------------- /pkgdown/favicon/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/pkgdown/favicon/apple-touch-icon.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/pkgdown/favicon/favicon-16x16.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/pkgdown/favicon/favicon-32x32.png -------------------------------------------------------------------------------- /pkgdown/favicon/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rpahl/container/cfbf739b5238a3c2617ff0a0846e2f1c8a441df8/pkgdown/favicon/favicon.ico -------------------------------------------------------------------------------- /tests/tinytest.R: -------------------------------------------------------------------------------- 1 | 2 | if ( requireNamespace("tinytest", quietly=TRUE) ){ 3 | tinytest::test_package("container") 4 | } 5 | 6 | --------------------------------------------------------------------------------