I modified to reset `next_id_` to be the size of `id2key`.