Learn R Programming

cppcontainers

The package makes C++ Standard Template Library containers interactively usable in R.

Advantages

A brief summary of the discussion in the vignette:

  • Speed up development workflows.
  • Use C++ data structures without a compiler.
  • Make C++ containers easily accessible to R users.
  • Push R towards general purpose language.
  • Bring performance of C++ containers to R.

Installation

An installation from source requires compilation. On Windows, you must, therefore, have Rtools installed.

Install the package from GitHub:

devtools::install_github("cdueben/cppcontainers", build_vignettes = T)

On various operating systems, you can skip the compilation step by installing the binary package from CRAN:

install.packages("cppcontainers")

User Guide

New users may want to consult the vignette for an introduction to the package. It, e.g., briefly introduces the container types and lists which method applies to which class.

Contribution

You are welcome to contribute by reporting issues on GitHub or by extending the package through pull requests. Guidelines on coding style and project organization are in inst/guidelines.md.

Copy Link

Version

Install

install.packages('cppcontainers')

Monthly Downloads

21

Version

1.0.4

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Christian Düben

Last Published

January 15th, 2025

Functions in cppcontainers (1.0.4)

cpp_list

Create list
cpp_unordered_multimap

Create unordered multimap
cpp_unordered_map

Create unordered map
cpp_priority_queue

Create priority queue
cpp_multiset

Create multiset
cpp_queue

Create queue
cpp_set

Create set
cpp_multimap

Create multimap
cpp_map

Create map
cpp_stack

Create stack
cpp_vector

Create vector
emplace

Add an element
emplace_front

Add an element to the front
empty

Check emptiness
insert

Add elements
max_size

Get maximum container size
max_load_factor

Get or set the maximum load factor
front

Access first element
cpp_unordered_set

Create unordered set
cpp_unordered_multiset

Create unordered multiset
insert_after

Add elements
==,CppSet,CppSet-method

Check equality
erase

Erase elements
insert_or_assign

Add or overwrite elements
flip

Toggle boolean values
emplace_back

Add an element to the back
merge

Merge two objects
erase_after

Erase elements
pop_back

Remove an element from the back
pop_front

Remove an element from the front
load_factor

Get the mean number of elements per bucket
emplace_after

Add an element
sort

Sort elements
pop

Remove top element
resize

Alter the container size
reserve

Reserve space
size

Get container size
push_back

Add an element to the back
rehash

Set minimum bucket count and rehash
max_bucket_count

Get the maximum number of buckets
remove.

Remove elements
print

Print container data
sorting

Print the sorting order
try_emplace

Add an element
splice

Move elements
push

Add elements
splice_after

Move elements
[,CppMap-method

Access or insert elements without bounds checking
unique

Delete consecutive duplicates
type

Get data type
to_r

Export data to R
shrink_to_fit

Shrink container capacity to size
top

Access top element
reverse

Reverse element order
push_front

Add an element to the front
clear

Clear the container
contains

Check for elements
bucket_count

Get the number of buckets
capacity

Get container capacity
count

Count element frequency
back

Access last element
cpp_forward_list

Create forward list
assign

Replace all elements
cpp_deque

Create deque
at

Access elements with bounds checking