Linked List used in MFC

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • xarzu
    New Member
    • Apr 2007
    • 90

    Linked List used in MFC

    What is the best way to make and use a linked list for MFC? Is it better to use one of the MFC classes? If so, which one? Or is it better to use a standard template library class and if so, which one?
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    If you are not going to be serialising the list then I would use an STL class. Conventional wisdom with the STL is to use a vector unless you have a good reason not to.

    Good reasons may be that you want to do a lot of inserts or deletes at the begining or in the middle of the list which has a fair bit of overhead in a vector. In which case you could use a list. Or that you need efficient random access by key, in which case a map may be more appropriate. Or that the object is the key in which case a set may be more appropriate.


    If you are going to be serialising the data in the list then use an MFC class because they support the MFC serialisation mechanism. a CList or possibly a CTypedPtrList.

    Comment

    Working...