Thread: Deleting itself ok?

  1. #16
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Don't be silly! Linked lists are powerfull structures! For one, unlike arrays, you can quickly morph them into multidimensional objects. Also, reorganizing a list is much faster and efficient than doing the same with an array. What makes you say they would be unnecessary in C++? Personally, I use them in 99% of my projects.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  2. #17
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    >Don't be silly! Linked lists are powerfull structures!

    I'm not being silly, nor am I suggesting that they are not powerful structures. Nor would I use an array of objects instead. I would use an object to hold a list of pointers.

    In VCL we have TList, I think the equivalent in the standard library is 'List'.

    If you can explain to me why a 'linked list' is more powerful than an object holding a list of pointers, then I'll withdraw my remark. I may even start using linked lists.

  3. #18
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >I may even start using linked lists.
    If the equivalent in the STL is std::list then you already are using linked lists. The std::list is usually implemented as a double linked list.

    > If you can explain to me why a 'linked list' is more powerful than an object holding a list of pointers, then I'll withdraw my remark.
    What do you think a linked list is? Most of the time this object will be implemented using a linked list. You're using an abstraction of the data structure, not a different data structure.

    -Prelude
    My best code is written with the delete key.

  4. #19
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    >> I would use an object to hold a list of pointers.

    Sounds like a linked list to me.

    And what is VCL?

    @Prelude: Please stop peddling your STL propaganda, who's payroll are you on anyway - tell us!!! j/k
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  5. #20
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >@Prelude: Please stop peddling your STL propaganda
    The who and the what? The only reason I mentioned the STL was because Davros did:

    >>In VCL we have TList, I think the equivalent in the standard library is 'List'.

    So there.

    -Prelude
    My best code is written with the delete key.

  6. #21
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Actually, I have been researching the STL quite a bit lately and I've had a change of heart about it. Can you believe I'm saying that?!!!
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  7. #22
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    >What do you think a linked list is?

    May be this is a good place to start. Here's what I always thought a linked list was.

    If you have a series of objects (or structures), then object1 holds a pointer to object2 & object2 holds a pointer to object3, etc.

    Whereas, something like TList holds the pointers to object1, object2, object3 & so on. Internally to TList, this will be implemented as an array of pointes (not an array of objects). There's nothing stopping me having a list with contains lists of lists, so as to make it mult-dimensional.

    I guess it's just a matter of where you place the control. With linked lists (or so I think) the control is distributed throughout the objects being linked. With a list object, the controlling is centralised.

    Perhaps it could be argued with a linked list, you could have multiple links to many objects, based on some arbitrary linkage scheme. In fact I have used such things, but have never regarded them as lists, rather they are a web.
    Last edited by Davros; 12-02-2002 at 11:51 AM.

  8. #23
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Interesting. Ok, I think I understand what you mean then.
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  9. #24
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    >And what is VCL?

    Borlands visual component library. In fact, many std classes have equivalents in VCL. I'm afraid I learned C++ (still learning obviously) by using Borland C++ Builder. This means I naturally adopted the use of VCL, rather than std library (although there's nothing stopping me using std).

    VCL is used in C++ Borland Builder because it binary compatible with object Pascal, or in other words Delphi. So a component for use in Delphi can also be used with C++ Builder.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  10. #25
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    >The std::list is usually implemented as a double linked list.

    Seems I need to take a closer look at List.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Creating and deleting directories and deleting files
    By fguy817817 in forum C Programming
    Replies: 1
    Last Post: 04-08-2009, 07:26 AM
  2. deleting nodes in a linear list
    By sudhanshu_nsit in forum C++ Programming
    Replies: 7
    Last Post: 06-25-2006, 02:00 AM
  3. Deleting dynamically allocated objects
    By Daniel Jurnove in forum C++ Programming
    Replies: 3
    Last Post: 11-07-2002, 03:30 AM
  4. Deleting Records from a structure
    By Simon in forum C Programming
    Replies: 5
    Last Post: 09-11-2002, 11:28 PM
  5. need help deleting a deleting a struct from file
    By Unregistered in forum C Programming
    Replies: 5
    Last Post: 05-20-2002, 05:38 AM