print-function: Print altWrapper vector values

Description Usage Arguments Value Examples

Description

This function is a complement of the print function. It is able to print an ALTREP object made by AltWrapper package. In case that the data pointer is not available, the function will look at ALTREP APIs in the order of getRegion, getSubset, getElement to search for the available way to collect the data.

Usage

1
2
3
4
## S3 method for class 'altWrapper'
print(x, ...)

printAltWrapper(x, ...)

Arguments

x

An altWrapper object

...

No effect, for compatibility only

Value

The argument x

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
length_func <- function(x) length(x)
element_function <- function(x,i) x[i]

## Define the altWrapper class and its functions
setAltClass(className = "example", classType = "integer")
setAltMethod(className = "example", getLength = length_func)
setAltMethod(className = "example", getElement = element_function)


## Create an altWrapper object by providing the class name and data.
A <- newAltrep(className = "example", x = 1L:10L)

## The default print function does not wrok since it uses
## data pointer only.
## Not run: 
A

## End(Not run)

## The package provide an alternative print function
printAltWrapper(A)

Jiefei-Wang/AltWrapper documentation built on Oct. 30, 2019, 7:43 p.m.