altrko's blog

By altrko, history, 4 hours ago, In English

how to make find function on set/multiset correspond to last element of that kind? like on multiset with elements 1 7 7 7 8 9 i want iterator pointing on last 7 on index 3.

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
4 hours ago, # |
  Vote: I like it +4 Vote: I do not like it

Just use upper_bound and then decrement the iterator once.

  • »
    »
    3 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Thanks so does lower_bound and find function do thr same thing?

    • »
      »
      »
      3 hours ago, # ^ |
      Rev. 2   Vote: I like it 0 Vote: I do not like it

      Nah, they both are different thing.

      But you can always check that, if your iterator is pointing towards the correct element you want to find.

      • »
        »
        »
        »
        3 hours ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        I dont get how are they different

        • »
          »
          »
          »
          »
          3 hours ago, # ^ |
            Vote: I like it 0 Vote: I do not like it

          Just search it on internet and you will get everything about it

          • »
            »
            »
            »
            »
            »
            45 minutes ago, # ^ |
              Vote: I like it 0 Vote: I do not like it

            ok thx