Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2010

    Question How to compare 2 Lists?


    I have two lists, QList<int>list1;and QList<int>list2; List1 have 20 elements and list2 have 10 elements. I want to compare these two list and also want to store the matched elements in third list.


  2. #2
    Super Contributor
    Join Date
    Oct 2009

    Re: How to compare 2 Lists?

    You can get idea how to do that from this sample program
    Complexity of algorithm is O(M * N), however, it can be reduced to O(M + N) in case lists are sorted.

  3. #3
    Super Contributor
    Join Date
    Jul 2008

    Re: How to compare 2 Lists?

    In case you are looking for a way to do this with a Qt call: forget it.

    I suggest you just u8se two for() lists, especially as the lists are so small...
    The lines above are the best I have to offer.If anyone of you is of more advanced knowledge, I ask for your patience and understanding! - unknown arab poet
    http://www.tamoggemon.com - Symbian blog - Windows Phone blog
    My other blogs:
    webOS blog iPhone blog BlackBerry blog Samsung bada blog Android blog

  4. #4
    Super Contributor
    Join Date
    Nov 2009
    Minnesota, USA

    Re: How to compare 2 Lists?

    Well, you either compare every element in one to every element in the other, with two nested loops, or you use qSort to sort the lists and step through them in sync with each other.

    Either way requires some actual programming skill, I'm afraid -- no cookbook.

Similar Threads

  1. how to compare 2 Dates?
    By rohanwaugh in forum Symbian User Interface
    Replies: 4
    Last Post: 2008-12-12, 11:28
  2. Lists within lists
    By flipflop82 in forum Symbian
    Replies: 0
    Last Post: 2005-02-08, 15:19
  3. Lists instead of menus
    By irishbeast in forum Symbian
    Replies: 3
    Last Post: 2004-08-16, 19:07
  4. How to implement simple lists ?
    By irishbeast in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-08-15, 16:44
  5. Nokia 30 recent call lists
    By colinc in forum Nokia M2M
    Replies: 0
    Last Post: 2004-03-08, 14:04

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts