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. STL / Custom Linked List

STL / Custom Linked List

Scheduled Pinned Locked Moved C / C++ / MFC
performancec++data-structuresquestion
8 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.
  • F Offline
    F Offline
    Fareed Rizkalla
    wrote on last edited by
    #1

    Which is better writing my own custom Linked List class or using STL? Which is better not just from the point of speed, but also memory usage?

    L M E 3 Replies Last reply
    0
    • F Fareed Rizkalla

      Which is better writing my own custom Linked List class or using STL? Which is better not just from the point of speed, but also memory usage?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      I don't know the answer, however I'm rather pragmatic on such issues: what makes you think your implementation would be better in some way (speed, memory, whatever)? :)

      Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

      F B 2 Replies Last reply
      0
      • L Luc Pattyn

        I don't know the answer, however I'm rather pragmatic on such issues: what makes you think your implementation would be better in some way (speed, memory, whatever)? :)

        Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

        F Offline
        F Offline
        Fareed Rizkalla
        wrote on last edited by
        #3

        Big-O-Notation!?

        L 1 Reply Last reply
        0
        • F Fareed Rizkalla

          Big-O-Notation!?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          That does not even start to look like the answer to my question. If you think you can design and build a better linked list, and can afford to spend the time to do it right, then do it, debug it, test it, document it, and compare it to existing implementations. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          1 Reply Last reply
          0
          • F Fareed Rizkalla

            Which is better writing my own custom Linked List class or using STL? Which is better not just from the point of speed, but also memory usage?

            M Offline
            M Offline
            Maximilien
            wrote on last edited by
            #5

            Fareed Rizkalla wrote:

            Which is better writing my own custom Linked List class or using STL?

            unless proven otherwise : STL.

            Fareed Rizkalla wrote:

            Which is better not just from the point of speed, but also memory usage?

            unless proven otherwise : STL, and if you really need to tweak something you can try to create and use your own allocator; but the time and effort needed for that is not that worthwhile. BUT if you have a very peculiar application that needs very customized linked list and does not care about portability, accessibility, expendability, write your own. Also, if you ever want to do some performance analysis of STL, remember to do it in RELEASE mode, the debug mode is considerably slower than release mode.

            Watched code never compiles.

            1 Reply Last reply
            0
            • F Fareed Rizkalla

              Which is better writing my own custom Linked List class or using STL? Which is better not just from the point of speed, but also memory usage?

              E Offline
              E Offline
              Emilio Garavaglia
              wrote on last edited by
              #6

              Custom lists are typically deployed when object need themselves to form a chain (objects that knows about their containment and know who is before and after. For this STL has no solution) Where no such need exist, a double linked list -however you implement it- can do nothing more that what std::list do. The algorithms to manage links are the same from about a century, and are nothing more that a swap between four pointers. The only advantage happens when you can code and test them faster then learning how STL methods and concept are defined. About portability ... Sorry but must disagree with many previous posts. Simply, I cannot understand how a self contained code that does nothing more pointer assignment, new and delete, cannot be portable. It can be buggy, but not unportable. Who speaks about "portability" is just doing "marketing lies" (and simply repeating acritically what read on STL books: The prove is that is using the exact same phrase -including adverbs and commas- everybody else sustaining the same thesis is using, so it's not his own original thought). The problem arise when your code need to interact with some other code doing his own implementation... and the two implementations conflict in prerequisite. But if normal good design rules are observed, I don't see that problem.

              2 bugs found. > recompile ... 65534 bugs found. :doh:

              1 Reply Last reply
              0
              • L Luc Pattyn

                I don't know the answer, however I'm rather pragmatic on such issues: what makes you think your implementation would be better in some way (speed, memory, whatever)? :)

                Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                B Offline
                B Offline
                Blake Miller
                wrote on last edited by
                #7

                I have done this where each node is an element but the forward and back 'pointers' are offsets from the base address to a block of memory, rather than individual 'nodes' allocated from the current process heap. If you put this into a custom Win32 Heap, then the entire list deletes almost instantly! I am not sure that is the case even if you feed the STL a custom allocator - it still asks for a node one at a time? Anyways, that was done years before STL existed.

                L 1 Reply Last reply
                0
                • B Blake Miller

                  I have done this where each node is an element but the forward and back 'pointers' are offsets from the base address to a block of memory, rather than individual 'nodes' allocated from the current process heap. If you put this into a custom Win32 Heap, then the entire list deletes almost instantly! I am not sure that is the case even if you feed the STL a custom allocator - it still asks for a node one at a time? Anyways, that was done years before STL existed.

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #8

                  I agree there can be circumstances where a specialized implementation (or even an entirely different data structure, e.g. some kind of tree) is (much) better; however the OP did not give any hint in that sense. :)

                  Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                  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