Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Managed C++/CLI
  4. How do you know the duplicate key insertion in STL map

How do you know the duplicate key insertion in STL map

Scheduled Pinned Locked Moved Managed C++/CLI
c++
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sarath_babu
    wrote on last edited by
    #1

    Is there any way to indiccate the insertion of duplicate key in STL map babu.p

    N 1 Reply Last reply
    0
    • S sarath_babu

      Is there any way to indiccate the insertion of duplicate key in STL map babu.p

      N Offline
      N Offline
      Nish Nishant
      wrote on last edited by
      #2

      sarath_babu wrote:

      Is there any way to indiccate the insertion of duplicate key in STL map

      You should ask this in the VC++ forum :- VC++ forum[^]

      C J 2 Replies Last reply
      0
      • N Nish Nishant

        sarath_babu wrote:

        Is there any way to indiccate the insertion of duplicate key in STL map

        You should ask this in the VC++ forum :- VC++ forum[^]

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Nish, C++/CLI is just plain too confusing for people. Most non MFC C++ questions seem to end up in here nowadays. Christian Graus - Microsoft MVP - C++

        N 1 Reply Last reply
        0
        • C Christian Graus

          Nish, C++/CLI is just plain too confusing for people. Most non MFC C++ questions seem to end up in here nowadays. Christian Graus - Microsoft MVP - C++

          N Offline
          N Offline
          Nish Nishant
          wrote on last edited by
          #4

          Christian Graus wrote:

          Nish, C++/CLI is just plain too confusing for people. Most non MFC C++ questions seem to end up in here nowadays.

          Uhm, if a guy cannot differentiate between MFC and C++/CLI, it's worth asking the question as to whether he's ready for either (MFC or C++/CLI). -- modified at 12:51 Tuesday 15th November, 2005

          C 1 Reply Last reply
          0
          • N Nish Nishant

            Christian Graus wrote:

            Nish, C++/CLI is just plain too confusing for people. Most non MFC C++ questions seem to end up in here nowadays.

            Uhm, if a guy cannot differentiate between MFC and C++/CLI, it's worth asking the question as to whether he's ready for either (MFC or C++/CLI). -- modified at 12:51 Tuesday 15th November, 2005

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            The point is that most people don't know what C++/CLI *means*, they assume it's a general C++ forum, as opposed to the Visual C++ forum, which they assume is for MFC and other 'visual' stuff. That's my observation, I learned ages ago to look in here every day, even though I know very little about CLI. Christian Graus - Microsoft MVP - C++

            J 1 Reply Last reply
            0
            • C Christian Graus

              The point is that most people don't know what C++/CLI *means*, they assume it's a general C++ forum, as opposed to the Visual C++ forum, which they assume is for MFC and other 'visual' stuff. That's my observation, I learned ages ago to look in here every day, even though I know very little about CLI. Christian Graus - Microsoft MVP - C++

              J Offline
              J Offline
              Jeremy Thornton
              wrote on last edited by
              #6

              Why on earth would a query about the C++ standard template library aka STL be in the microsoft foundation class or visual C++ forum? :confused: I doubt that Alexander Stepanov and Meng Lee at Hewlett-Packard in Palo Alto, California, Dave Musser at General Electric's Research Center in Schenectady, New York, Andrew Koenig, and of course "Mr C++" himself, Bjarne Stroustrup at AT&T Bell Laboratories would put such a query in a MS forum? And rather than give out a terse (bordering on rude) reply like Nish's why not suggest an answer and if it genuinely belongs in another forum educate the user so? Dissapointed I am :(

              T C 2 Replies Last reply
              0
              • N Nish Nishant

                sarath_babu wrote:

                Is there any way to indiccate the insertion of duplicate key in STL map

                You should ask this in the VC++ forum :- VC++ forum[^]

                J Offline
                J Offline
                Jeremy Thornton
                wrote on last edited by
                #7

                You have to test!:) A STL map can only store one value per key. If you use a second instance of the key it will supercede the existing one. If this is not intended then you should use a multimap. You can see if a key is pre-existing by using the maps own find method and comaparing the result with the map's end iterator. If it reaches the end it isnt in the map :doh:

                map::iterator it
                it = some_map_or_other.find( the_key );
                if ( it != some_map_or_other.end() ) {
                //the key exists
                }

                further, you can test if an item already exists in a map with the single arguement version of insert. This method returns a STL pair cpnsisting of an iterator & a bool. Now if the insertion was unsuccesful the bool will be false and the iterator will be at the duplicate key. hope this helps? -- modified at 8:46 Thursday 24th November, 2005

                1 Reply Last reply
                0
                • J Jeremy Thornton

                  Why on earth would a query about the C++ standard template library aka STL be in the microsoft foundation class or visual C++ forum? :confused: I doubt that Alexander Stepanov and Meng Lee at Hewlett-Packard in Palo Alto, California, Dave Musser at General Electric's Research Center in Schenectady, New York, Andrew Koenig, and of course "Mr C++" himself, Bjarne Stroustrup at AT&T Bell Laboratories would put such a query in a MS forum? And rather than give out a terse (bordering on rude) reply like Nish's why not suggest an answer and if it genuinely belongs in another forum educate the user so? Dissapointed I am :(

                  T Offline
                  T Offline
                  toxcct
                  wrote on last edited by
                  #8

                  i do agree perfectly... so here comes my question : why do you continue the thread instead of ignoring it ? if you don't agree with some things, use the voting to express your feeling about that... (which is what i am going to do now :D )


                  TOXCCT >>> GEII power
                  [toxcct][VisualCalc]

                  1 Reply Last reply
                  0
                  • J Jeremy Thornton

                    Why on earth would a query about the C++ standard template library aka STL be in the microsoft foundation class or visual C++ forum? :confused: I doubt that Alexander Stepanov and Meng Lee at Hewlett-Packard in Palo Alto, California, Dave Musser at General Electric's Research Center in Schenectady, New York, Andrew Koenig, and of course "Mr C++" himself, Bjarne Stroustrup at AT&T Bell Laboratories would put such a query in a MS forum? And rather than give out a terse (bordering on rude) reply like Nish's why not suggest an answer and if it genuinely belongs in another forum educate the user so? Dissapointed I am :(

                    C Offline
                    C Offline
                    Christian Graus
                    wrote on last edited by
                    #9

                    Jeremy Thornton wrote:

                    Why on earth would a query about the C++ standard template library aka STL be in the microsoft foundation class or visual C++ forum?

                    Because the STL forum also caters to ATL and WTL, yet is a ghost town ? A lot of people do not know what CLI is, and assume that this forum is for 'standard C++' questions.

                    Jeremy Thornton wrote:

                    I doubt that Alexander Stepanov and Meng Lee at Hewlett-Packard in Palo Alto, California, Dave Musser at General Electric's Research Center in Schenectady, New York, Andrew Koenig, and of course "Mr C++" himself, Bjarne Stroustrup at AT&T Bell Laboratories would put such a query in a MS forum?

                    Who gives a toss what they would do ? People who are learning C++ are now required to understand it well enough to know which bits are STL before they are allowed to ask for help ? Christian Graus - Microsoft MVP - C++

                    J 1 Reply Last reply
                    0
                    • C Christian Graus

                      Jeremy Thornton wrote:

                      Why on earth would a query about the C++ standard template library aka STL be in the microsoft foundation class or visual C++ forum?

                      Because the STL forum also caters to ATL and WTL, yet is a ghost town ? A lot of people do not know what CLI is, and assume that this forum is for 'standard C++' questions.

                      Jeremy Thornton wrote:

                      I doubt that Alexander Stepanov and Meng Lee at Hewlett-Packard in Palo Alto, California, Dave Musser at General Electric's Research Center in Schenectady, New York, Andrew Koenig, and of course "Mr C++" himself, Bjarne Stroustrup at AT&T Bell Laboratories would put such a query in a MS forum?

                      Who gives a toss what they would do ? People who are learning C++ are now required to understand it well enough to know which bits are STL before they are allowed to ask for help ? Christian Graus - Microsoft MVP - C++

                      J Offline
                      J Offline
                      Jeremy Thornton
                      wrote on last edited by
                      #10

                      I'm sorry my views drove you to angry expletive I have tried to move what I thought was an important topic to the suggestions forum.

                      Christian Graus wrote:

                      People who are learning C++ are now required to understand it well enough to know which bits are STL before they are allowed to ask for help ?

                      No that is the opposite of what I had intended to convey.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups