Joined: 25 Jun 2004 Posts: 130 Location: Liverpool(home) or Derby(uni), UK votes: 3
Posted: Tue Oct 17, 2006 12:50 pm Post subject: Removing array duplicates
I have made this little program which works with myspace. You give it a start and end profile id, and it will use the top friends list to find a path from the start profile to the end. I have an array to store the IDs that still have to be processed, and each time one is processed, the array expands by a multiple of 4 between 4 and 28. When I get the ids though, I dont want to add duplicates to the list of ids still to process. I was wondering if someone could give me the best way to remove duplicates from a very large array, whilst still preserving the order in which the values were pushed into it?
Joined: 19 Jul 2004 Posts: 556 Location: Los Angeles, CA votes: 1
Posted: Tue Oct 17, 2006 6:30 pm Post subject:
He said he wanted to keep the order of the array (because he is looking at the top list), but keys of a hash will not be in the same order that you added them.
This will use a hash just to check if we have used it yet so we maintain the order.