|
-
Sep 2nd, 2011, 10:09 AM
#1
Thread Starter
Frenzied Member
[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.
-
Sep 2nd, 2011, 01:01 PM
#2
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
-
Sep 2nd, 2011, 07:37 PM
#3
Thread Starter
Frenzied Member
Re: Find two arrays difference
 Originally Posted by LaVolpe
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.
-
Sep 2nd, 2011, 09:50 PM
#4
Re: Find two arrays difference
 Originally Posted by Jonney
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?
-
Sep 2nd, 2011, 10:07 PM
#5
Thread Starter
Frenzied Member
Re: Find two arrays difference
 Originally Posted by seenu_1st
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|