V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
stupidcat
V2EX  ›  问与答

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

  •  
  •   stupidcat · Dec 10, 2014 · 5638 views
    This topic created in 4165 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   ·   893 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 21:43 · PVG 05:43 · LAX 14:43 · JFK 17:43
    ♥ Do have faith in what you're doing.