Consider using std::set instead here, otherwise this will end up an `O(n^2)` operation.