stdvectorClass: std::vector R wrapper

Description Usage Arguments Details Value Note References Examples

Description

Create and manipulate a C++ std:::vector in R.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
stdvectorCreate(type = "double", reserve = 0L)
stdvectorPushBack(sdv, values)
stdvectorSize(sdv)
stdvectorClear(sdv)
stdvectorToVector(sdv)
stdvectorSubset(sdv,indexes)
stdvectorReplace(sdv,indexes,values)
stdvectorErase(sdv,indexFrom,indexTo)
stdvectorClone(sdv)
is.stdvector(x)
## S3 method for class 'stdvector'
print(x, ...)
## S3 method for class 'stdvector'
toString(x, ...)

Arguments

type

Character string indicating the type of the vector; possible values: double,numeric,integer,logical,character,any.

reserve

The number of slots to be pre-allocated in the stdvector.

sdv

A stdvector object, as returned by stdvectorCreate.

...

optional arguments passed to inner print and toString methods. Unused.

x

A stdvector object, as returned by stdvectorCreate.

values

Values to be appended (in stdvectorPushBack) or set (in stdvectorReplace).

indexes

Indexes used to subset the current stdvector, in case of out of bounds indexes an error will be raised.

indexFrom

Used by stdvectorErase as starting index (inclusive) for the range of elements to be removed from stdvector.

indexTo

Used by stdvectorErase as ending index (inclusive) for the range of elements to be removed from stdvector.

Details

Value

Note

stdvector

References

See http://en.cppreference.com/w/cpp/container/vector

Examples

1
2
3
4
5
6
7
8
9
  # create a stdvector
  sv <- stdvectorCreate('integer')
  # add 100 values to it
  for(i in 1:100){
    # note that sv is modified in-place
    stdvectorPushBack(sv,i)
  }
  # get a normal R vector from the stdvector
  v <- stdvectorToVector(sv)

stdvectors documentation built on May 1, 2019, 9:18 p.m.