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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CMap efficiency

CMap efficiency

Scheduled Pinned Locked Moved C / C++ / MFC
question
4 Posts 4 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.
  • E Offline
    E Offline
    econy
    wrote on last edited by
    #1

    Hi, if Key-Value pairs are like:

    40000 "40000 is a first number"
    41020 "41020 is a second number"
    ....

    use CMapStringToString or CMap to store. Then which one is better in look up efficiency? CMapStringToString or CMap

    J CPalliniC S 3 Replies Last reply
    0
    • E econy

      Hi, if Key-Value pairs are like:

      40000 "40000 is a first number"
      41020 "41020 is a second number"
      ....

      use CMapStringToString or CMap to store. Then which one is better in look up efficiency? CMapStringToString or CMap

      J Offline
      J Offline
      jeron1
      wrote on last edited by
      #2

      econy wrote:

      Then which one is better in look up efficiency?

      I don't know, but I cannot imagine having to convert between ints and CStrings just to use the CMapStringToString could possibly be worth it, I would start with the CMap.

      1 Reply Last reply
      0
      • E econy

        Hi, if Key-Value pairs are like:

        40000 "40000 is a first number"
        41020 "41020 is a second number"
        ....

        use CMapStringToString or CMap to store. Then which one is better in look up efficiency? CMapStringToString or CMap

        CPalliniC Offline
        CPalliniC Offline
        CPallini
        wrote on last edited by
        #3

        Why don't you test that?

        Veni, vidi, vici.

        In testa che avete, signor di Ceprano?

        1 Reply Last reply
        0
        • E econy

          Hi, if Key-Value pairs are like:

          40000 "40000 is a first number"
          41020 "41020 is a second number"
          ....

          use CMapStringToString or CMap to store. Then which one is better in look up efficiency? CMapStringToString or CMap

          S Offline
          S Offline
          Stefan_Lang
          wrote on last edited by
          #4

          Lookup requires comparing keys, i. e. calling the operator < and maybe operator ==. Since these operators are more efficient for ints than they are for strings, I suspect that CMap is better. However, the rest of the looking-up algorithm that does not involve comparing keys may play a much more significant role on performance overall, so you might not notice a difference. You should also consider whether there are other operations than looking up which are called often, e. g. insertion, removal, converting keys to different formats, etc.: E. g. if you spend a lot of time reading keys from a text source or writing them as text, then it may be advisable to just stick with string keys rather than converting them back and forth all the time!

          GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto) Point in case: http://www.infoq.com/news/2014/02/apple_gotofail_lessons[^]

          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