Results 1 to 7 of 7

Thread: QList or QLinkedList

  1. #1
    Join Date
    Nov 2006
    Posts
    96

    Default QList or QLinkedList

    Hi all, I need to do this: http://shrani.si/f/2a/sv/2f6VXI8r/fesf.png

    I have a couple of questions:

    1) what should I use for this: QList or QLinkedList

    2) for every black circle I need 1 QList right?

    3) for every blue connections I need a new QList right?

    Am I assuming this correctly, or can I do this with fewer QList's without complications?

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QList or QLinkedList

    you didn't specify enough information for an answer.
    What are the rules in the lists?
    The "blue" lists vary in number of items - does this mean each item can both link to the "black" list AND the "blue" list?
    The relationships are also problematic, since it looks like there is recursiveness - head1 links to head two (in the inner black circle) head two has a "blue" list members of which the last one links to the last blue item of head1 again, since the blue connections go both ways its recursive...
    So you will have to explain more...
    But on it looks to me that linked lists is what you need.

    And please, post images on the forum it self, don't post links, since links will not stay for ever, and later it will be impossible to know what the thread is about.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Nov 2006
    Posts
    96

    Default Re: QList or QLinkedList

    For now I just want to know this:

    1) for every black circle I need 1 QLinkedList right?
    - you can travel over black circles only in one direction

    2) for every blue connections I need a new QLinkedList right?
    - over blue circles you can travel in both directions

    I just want to know how to store those...for now.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QList or QLinkedList

    yes, I think you will need a link list of linked lists - that is, a link lists which each of its elements is a linked list.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Nov 2006
    Posts
    96

    Default Re: QList or QLinkedList

    Hi, can somebody give me an idea, how to make recursive search of 2 stations (starting one + ending one) ?

    This is a railway(look at the picture) where you enter a station and get off on another station. Now I have to make recursive search how to find the shorthest path between these two stations.

    Thanks

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QList or QLinkedList

    Quote Originally Posted by eleanor View Post
    Now I have to make recursive search how to find the shorthest path between these two stations.
    Use Dijkstra's algorithm, although the implementation might be a bit tricky with such non-standard representation of a graph.

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: QList or QLinkedList

    in case each station is connected to not more then two other stations, you could use a binary search tree, which is easy.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. Sorting using qSort(), - if QList contains POINTERS
    By joseph in forum Qt Programming
    Replies: 13
    Last Post: 18th August 2013, 18:55
  2. Q3Ptrlist v/s QList
    By joseph in forum Qt Programming
    Replies: 3
    Last Post: 25th September 2007, 11:27
  3. QList
    By dragon in forum Qt Programming
    Replies: 11
    Last Post: 9th May 2007, 20:15
  4. using Qlist with a class
    By Havard in forum Qt Programming
    Replies: 10
    Last Post: 24th February 2007, 19:38
  5. Accessing QList Objects
    By magikalpnoi in forum Qt Programming
    Replies: 7
    Last Post: 21st September 2006, 20:43

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.