You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All R objects have attributes, which can be queried and modified with `.attr()`.
511
511
cpp11 also provides `.names()` as an alias for the `names` attribute.
512
512
The following code snippet illustrates these methods.
513
-
Note the use of `{}`[initializer list](https://en.cppreference.com/w/cpp.html/utility/initializer_list) syntax.
513
+
Note the use of `{}`[initializer list](https://en.cppreference.com/w/cpp/utility/initializer_list.html) syntax.
514
514
This allows you to create an R vector from C++ scalar values:
515
515
516
516
```{r attribs, engine = "cpp11"}
@@ -736,7 +736,7 @@ local({
736
736
### Algorithms
737
737
738
738
The `<algorithm>` header provides a large number of algorithms that work with iterators.
739
-
A good reference is available at <https://en.cppreference.com/w/cpp.html/algorithm>.
739
+
A good reference is available at <https://en.cppreference.com/w/cpp/algorithm.html>.
740
740
For example, we could write a basic cpp11 version of `findInterval()` that takes two arguments, a vector of values and a vector of breaks, and locates the bin that each x falls into.
741
741
This shows off a few more advanced iterator features.
742
742
Read the code below and see if you can figure out how it works.
@@ -790,7 +790,7 @@ The most important of these data structures are the `vector`, the `unordered_set
790
790
We'll focus on these three in this section, but using the others is similar: they just have different performance trade-offs.
791
791
For example, the `deque` (pronounced "deck") has a very similar interface to vectors but a different underlying implementation that has different performance trade-offs.
792
792
You may want to try it for your problem.
793
-
A good reference for STL data structures is <https://en.cppreference.com/w/cpp.html/container> --- I recommend you keep it open while working with the STL.
793
+
A good reference for STL data structures is <https://en.cppreference.com/w/cpp/container.html> --- I recommend you keep it open while working with the STL.
794
794
795
795
cpp11 knows how to convert from many STL data structures to their R equivalents, so you can return them from your functions without explicitly converting to R data structures.
796
796
@@ -843,7 +843,7 @@ list rle_cpp(doubles x) {
843
843
(An alternative implementation would be to replace `i` with the iterator `lengths.rbegin()` which always points to the last element of the vector.
844
844
You might want to try implementing that.)
845
845
846
-
Other methods of a vector are described at <https://en.cppreference.com/w/cpp.html/container/vector>.
846
+
Other methods of a vector are described at <https://en.cppreference.com/w/cpp/container/vector.html>.
847
847
848
848
### Sets
849
849
@@ -854,7 +854,7 @@ Unordered sets can somtimes be much faster (because they use a hash table intern
854
854
Often even if you need an ordered set, you could consider using an unordered set and then sorting the output.
855
855
Benchmarking with your expected dataset is the best way to determine which is fastest for your data.
856
856
Like vectors, sets are templated, so you need to request the appropriate type of set for your purpose: `unordered_set<int>`, `unordered_set<bool>`, etc.
857
-
More details are available at <https://en.cppreference.com/w/cpp.html/container/set> and <https://en.cppreference.com/w/cpp.html/container/unordered_set>.
857
+
More details are available at <https://en.cppreference.com/w/cpp/container/set.html> and <https://en.cppreference.com/w/cpp/container/unordered_set.html>.
858
858
859
859
The following function uses an unordered set to implement an equivalent to `duplicated()` for integer vectors.
0 commit comments