crossbind
GitHub

Vectors and maps

A std::vector parameter takes a plain array. A vector or a map that C++ returns arrives as an object with methods of its own.

mean takes a std::vector<double> and main.js hands it an array. split returns a std::vector<std::string>, which m.toArray turns into an array; m is the module initNative() resolves to.

countWords returns a std::map<std::string, int>, read with get(key) and size(). In a Web Worker a returned vector is a plain array already; toArray takes both, so the same line works there.

Try it
Split a sentence on its spaces, and look up a word that is not in counts.
Open in playground
Runs without a compile until the C++, Rust, packages or imports change.
Press Run, or Ctrl+Enter, to run main.js.
Type to search every guide page and section.
↑↓ navigate↵ openesc close