c++ push_back() inside a map of vectors

后端 未结 1 1423
醉梦人生
醉梦人生 2021-02-10 01:50

I\'m trying to dynamically add elements to a vector that is contained within a map, to store multiple arrays of \"Particle\" objects that are mapped to different ids. I\'m new t

1条回答
  •  遇见更好的自我
    2021-02-10 01:57

    particleMap[currentId].push_back(p);
    

    will work just fine.

    There is only one vector per id; this is what you are referring to with particleMap[currentId]. Then you just continue with the expression as if you were writing myVector.push_back(p).

    0 讨论(0)
提交回复
热议问题