stupidcat
V2EX  ›  问与答

std::multiset 如何删除多个相同元素中的某一个?

  •  
  •   stupidcat · Dec 10, 2014 · 5682 views
    This topic created in 4186 days ago, the information mentioned may be changed or developed.
    比如现在multiset里是{10 20 30 40 40 40 50 60},如果使用erase(40)的话,会把所有的40都删除了,得到{10 20 30 50 60}
    但是我现在只想删除一个40,应该怎么搞。。。?是不是只有“先erase(40),然后再insert回去,直到比原来少一个”这种傻方法了。。。?
    stupidcat
        1
    stupidcat  
    OP
       Dec 10, 2014
    。。。。。。我太naive了 可以沉了
    medianSet.erase(medianSet.find(40));
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   952 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:13 · PVG 05:13 · LAX 14:13 · JFK 17:13
    ♥ Do have faith in what you're doing.