R/collections.R

Defines functions cls dict_hash

Documented in cls

#' @docType package
#' @useDynLib collections, .registration = TRUE, .fixes = "C_"
"_PACKAGE"

dict_hash <- function(key) .Call(C_dict_hash, key)

#' @title Inspect objects
#' @description
#' `cls` is a replacement for the `class` function
#' which also works for the collection objects. It falls back to the ordinary `class` function
#' for other objects.
#' @param x a collection object
#' @examples
#' d <- dict()
#' cls(d)
#' @export
cls <- function(x) {
    if (is.environment(x) && identical(parent.env(x), asNamespace("collections"))) {
        return(x$.__class__)
    }
    return(class(x))
}

Try the collections package in your browser

Any scripts or data that you put into this service are public.

collections documentation built on Aug. 11, 2020, 1:06 a.m.