Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 3
    Just a quick comment: you can replace (allPlayers.empty() == false) by just saying (!allPlayers.empty()). This is because empty() returns a boolean type: if the vector is empty it will return true. Using the "not" operator is like saying "if it's NOT true that the vector is empty". Just to prettify your code :) Commented Oct 17, 2016 at 13:04
  • @Anarelle Thanks! Commented Nov 3, 2016 at 6:47
  • 1
    This reminds me that I should NOT erase from the beginning (i == 0). Because each time erase() is called, then begin() will be changed at the same time. begin() + i will be changed according to new vector (one item was just erased). If erase from the end to beginning, it will be OK. Thanks:) Commented Dec 12, 2017 at 16:07
  • 1
    This will yield valid result, but is inefficient as can be, as subsequent elements will be moved repeatedly towards front for each element removed. Commented Sep 14, 2018 at 2:00