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 class questions [Solved]

CMap class questions [Solved]

Scheduled Pinned Locked Moved C / C++ / MFC
8 Posts 3 Posters 1 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

    I use a CmapStringToString object, put over 10000 key-value pairs into the object. But I use: test1 = mStrMap.GetCount(); test2 = mStrMap.GetHashTableSize(); try to get the map size. test1 = 0x00000299 test2 = 0x00000011 I wonder what the meaning of GetCount(), and GetHashTableSize();

    CPalliniC L 2 Replies Last reply
    0
    • E econy

      I use a CmapStringToString object, put over 10000 key-value pairs into the object. But I use: test1 = mStrMap.GetCount(); test2 = mStrMap.GetHashTableSize(); try to get the map size. test1 = 0x00000299 test2 = 0x00000011 I wonder what the meaning of GetCount(), and GetHashTableSize();

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

      With the following code

      CMapStringToString mss;
      //mss.InitHashTable(32767);

      for (int i=0; i<10000; ++i)
      {
      CString k,v;
      k.Format("%05d", i);
      v.Format("Foo%02d", i%100);
      mss[k] = v;
      }
      int count = mss.GetCount();
      int hsize = mss.GetHashTableSize();

      I get: count = 10000 hsize = 17 I don't know what exactly GetHashTableSize returns, the documentation is not much detailed about.

      Veni, vidi, vici.

      In testa che avete, signor di Ceprano?

      E 1 Reply Last reply
      0
      • E econy

        I use a CmapStringToString object, put over 10000 key-value pairs into the object. But I use: test1 = mStrMap.GetCount(); test2 = mStrMap.GetHashTableSize(); try to get the map size. test1 = 0x00000299 test2 = 0x00000011 I wonder what the meaning of GetCount(), and GetHashTableSize();

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        See http://msdn.microsoft.com/en-us/library/9ah6bd2h.aspx[^] for details about the hash table size. Are you certain you added 1000 items?

        E 2 Replies Last reply
        0
        • CPalliniC CPallini

          With the following code

          CMapStringToString mss;
          //mss.InitHashTable(32767);

          for (int i=0; i<10000; ++i)
          {
          CString k,v;
          k.Format("%05d", i);
          v.Format("Foo%02d", i%100);
          mss[k] = v;
          }
          int count = mss.GetCount();
          int hsize = mss.GetHashTableSize();

          I get: count = 10000 hsize = 17 I don't know what exactly GetHashTableSize returns, the documentation is not much detailed about.

          Veni, vidi, vici.

          E Offline
          E Offline
          econy
          wrote on last edited by
          #4

          My fault, checked again, GetCount() works well for me too.

          1 Reply Last reply
          0
          • L Lost User

            See http://msdn.microsoft.com/en-us/library/9ah6bd2h.aspx[^] for details about the hash table size. Are you certain you added 1000 items?

            E Offline
            E Offline
            econy
            wrote on last edited by
            #5

            Sorry, my fault, checked again, GetCount() return value is right. but don't know what is the meaning of GetHashTableSize();

            L 1 Reply Last reply
            0
            • L Lost User

              See http://msdn.microsoft.com/en-us/library/9ah6bd2h.aspx[^] for details about the hash table size. Are you certain you added 1000 items?

              E Offline
              E Offline
              econy
              wrote on last edited by
              #6

              Determines the number of elements in the hash table for the map. // msdn: GetHashTableSize(); Retrieves the number of elements in the map. //msdn: GetCount() And I read some articles, they say Hashmap is equivalent to Hashtable. So, what is the difference between GetCount() and GetHashSize() confused me

              L 1 Reply Last reply
              0
              • E econy

                Sorry, my fault, checked again, GetCount() return value is right. but don't know what is the meaning of GetHashTableSize();

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                That's why I gave you a link to the MSDN page that explains it.

                1 Reply Last reply
                0
                • E econy

                  Determines the number of elements in the hash table for the map. // msdn: GetHashTableSize(); Retrieves the number of elements in the map. //msdn: GetCount() And I read some articles, they say Hashmap is equivalent to Hashtable. So, what is the difference between GetCount() and GetHashSize() confused me

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  econy wrote:

                  So, what is the difference between GetCount() and GetHashSize()

                  GetCount returns the number of elements in the Map, e.g. 1000. GetHashSize gives the size of the Hash table that is used to manage the Map; in most cases this information is not useful to you.

                  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