Results 1 to 5 of 5

Thread: [RESOLVED] Find two arrays difference

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Resolved [RESOLVED] Find two arrays difference

    Who got Ready-to-use function to manipulate arrays:

    1. Combine two arrays with removing duplicated items
    2. Find two arrays difference, then make a new array filled with all of the different items

    Both the two arrays can be string or Long type.
    Thanks in advance.

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: Find two arrays difference

    Method 1: Listbox. It will contain your results
    When I say search listbox, use SendMessage API with LB_FINDSTRINGEXACT for fast searching
    1. Fill listbox with largest array
    2. For each second array member, search listbox
    ::Combining arrays:
    - Found? Ignore & move on to next array item
    - Not found? Add to listbox
    :: Difference in arrays
    - Found? Remove item from listbox
    - Not found? Add to listbox

    Method 2. Pure code, no listbox. Pretty much same method above, but would probably be far more efficient if one of the arrays were sorted first. If sorted, the binary search algorithm can be used to find a duplicate in very few iterations (less than 20 iterations for 1 million items).

    1. Copy largest array which will be your result array; ensure sorted for binary algo
    2. For each item in other array, search results array & return either position found or insertion position
    :: Combining?
    - Found? Ignore and move on to next array item
    - Not found? Insert into array at sorted position
    :: Difference in arrays
    - Found? Remove results array item
    - Not found? Insert into array at sorted position
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: Find two arrays difference

    Quote Originally Posted by LaVolpe View Post
    Method 1: Listbox. It will contain your results
    When I say search listbox, use SendMessage API with LB_FINDSTRINGEXACT for fast searching
    1. Fill listbox with largest array
    2. For each second array member, search listbox
    ::Combining arrays:
    - Found? Ignore & move on to next array item
    - Not found? Add to listbox
    :: Difference in arrays
    - Found? Remove item from listbox
    - Not found? Add to listbox

    Method 2. Pure code, no listbox. Pretty much same method above, but would probably be far more efficient if one of the arrays were sorted first. If sorted, the binary search algorithm can be used to find a duplicate in very few iterations (less than 20 iterations for 1 million items).

    1. Copy largest array which will be your result array; ensure sorted for binary algo
    2. For each item in other array, search results array & return either position found or insertion position
    :: Combining?
    - Found? Ignore and move on to next array item
    - Not found? Insert into array at sorted position
    :: Difference in arrays
    - Found? Remove results array item
    - Not found? Insert into array at sorted position
    Thanks. I am lazy and not willing to spend time for debugging. A ready-to-go is appreciated,but I didn't find the exact one in website.

  4. #4
    Just a Member! seenu_1st's Avatar
    Join Date
    Aug 2007
    Location
    India
    Posts
    2,170

    Re: Find two arrays difference

    Quote Originally Posted by Jonney View Post
    Thanks. I am lazy and not willing to spend time for debugging. A ready-to-go is appreciated,but I didn't find the exact one in website.
    if u r not willing to spend time for ur work, then who wil spend?
    Seenu

    If this post is useful, pls don't forget to Rate this post.
    Pls mark thread as resolved once ur problem solved.
    ADO Tutorial Variable types SP6 for VB6, MsFlexGrid fast fill, Sorting Algorithms


  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2010
    Posts
    1,103

    Re: Find two arrays difference

    Quote Originally Posted by seenu_1st View Post
    if u r not willing to spend time for ur work, then who wil spend?
    You are misunderstanding. VB6 has over 10 years history and was about obsolete. I am wondering whether it is worth to spend time to write basic functions like what I am asking.
    Thread is closed.

Posting Permissions

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



Click Here to Expand Forum to Full Width