C++ code works - slower than vectorized R!
Most likely due to my numerous type conversion in the hope of leveraging hashmaps. Maybe simple loop would be best, or unordered lists.