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. C / C++ / MFC
  4. CDWordArray and sort

CDWordArray and sort

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
6 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.
  • P Offline
    P Offline
    pranavamhari
    wrote on last edited by
    #1

    hi, I have a CDWordArray with many items. I need to sort it, in the quickest possible way. Please tell me how to do it. the code I use now is, void CSortableDWordArray::Sort(DWORDCOMPAREFN pfnCompare) { DWORD * prgdw = GetData(); qsort(prgdw,GetSize(),sizeof(DWORD),(GENERICCOMPAREFN)pfnCompare); } It does not seem to be very fast. regards hari Hari Krishnan

    B 1 Reply Last reply
    0
    • P pranavamhari

      hi, I have a CDWordArray with many items. I need to sort it, in the quickest possible way. Please tell me how to do it. the code I use now is, void CSortableDWordArray::Sort(DWORDCOMPAREFN pfnCompare) { DWORD * prgdw = GetData(); qsort(prgdw,GetSize(),sizeof(DWORD),(GENERICCOMPAREFN)pfnCompare); } It does not seem to be very fast. regards hari Hari Krishnan

      B Offline
      B Offline
      bryce
      wrote on last edited by
      #2

      how many items do you have in your array? Bryce --- Publitor, making Pubmed easy. http://www.sohocode.com/publitor

      P 1 Reply Last reply
      0
      • B bryce

        how many items do you have in your array? Bryce --- Publitor, making Pubmed easy. http://www.sohocode.com/publitor

        P Offline
        P Offline
        pranavamhari
        wrote on last edited by
        #3

        thanks, About 10,000 to 20,000. Another question, how about adding the items sorted while it is being added ? Which is faster. Also, how can i use heapsort ? regards hari Hari Krishnan

        L J B 3 Replies Last reply
        0
        • P pranavamhari

          thanks, About 10,000 to 20,000. Another question, how about adding the items sorted while it is being added ? Which is faster. Also, how can i use heapsort ? regards hari Hari Krishnan

          L Offline
          L Offline
          l a u r e n
          wrote on last edited by
          #4

          shouldnt u be looking at binary trees?


          "there is no spoon"
          biz stuff   about me

          1 Reply Last reply
          0
          • P pranavamhari

            thanks, About 10,000 to 20,000. Another question, how about adding the items sorted while it is being added ? Which is faster. Also, how can i use heapsort ? regards hari Hari Krishnan

            J Offline
            J Offline
            jhwurmbach
            wrote on last edited by
            #5

            std::set from the STL does exactly this: hold a sorted collection of objects. Depending on the access pattern you use with your collection, it may or may not be what you want.


            Who is 'General Failure'? And why is he reading my harddisk?!?

            1 Reply Last reply
            0
            • P pranavamhari

              thanks, About 10,000 to 20,000. Another question, how about adding the items sorted while it is being added ? Which is faster. Also, how can i use heapsort ? regards hari Hari Krishnan

              B Offline
              B Offline
              bryce
              wrote on last edited by
              #6

              ok 10k -> 20k how long does it take to sort and how fast is your PC etc Bryce --- Publitor, making Pubmed easy. http://www.sohocode.com/publitor

              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