We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Compare two lists

Last post 04-25-2008 7:09 PM by asadabbasi. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 03-26-2008 6:52 PM

    • Snimon
    • Not Ranked
    • Joined on 11-22-2007
    • United Kingdom
    • New Member
    • Points 15

    Compare two lists

     What i want to do is compare two lists, and then view which items have been added/removed.

    So, for example:

    List1:

    bob
    jack
    tim
    dave
    john

    Compared with list2:

    bob
    alan
    jack
    tim
    george
    john

    would show that alan and george were added and that dave was removed.

    How would i go about this? 

    • Post Points: 10
  • 04-25-2008 7:09 PM In reply to

    Re: Compare two lists

    I believe by now you would already have solved your problem. If no, here is what you can do:

    1. Overload subtraction operator (or write a function Difference) that takes two lists List1 and List 2 as parameters and returns a list of
    all members of List1 that are not in List2.

    2. With this List1 - List2 (or Difference(List1, List2)) will give you all items removed and List2 - List1 (or Difference(List2, List1) will
    give all items added to go from List1 to List2.
     

    Hope I understood your problem correctly and that this solution helps.

     
    Asad 

    • Post Points: 5
Page 1 of 1 (2 items)