playMaker

Author Topic: duplicates in an array/hash[SOLVED]  (Read 1492 times)

Splankton

  • Sr. Member
  • ****
  • Posts: 268
duplicates in an array/hash[SOLVED]
« on: June 05, 2014, 02:13:19 PM »
Hi
I have a simple hash table that iterates a few times to get a random name from an arraylist, and add that into a hash table as the key(string) and it's index(int).
It all works fine except i sometimes get 2 duplicate indexes.
So it looks a bit like this
Mike 6
Dave 3
Rob 2
Joe 5 *
Steve 0
Chris 5 *

By the way, I never get name duplicates.
I made a temp arraylist that copies from the source array, so I can get a random name, then remove it from the array, leaving the source array free from any removing.
So I don't get why I sometimes get duplicates?
Can someone help?
« Last Edit: June 10, 2014, 04:47:53 AM by jeanfabre »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: duplicates in an array/hash
« Reply #1 on: June 06, 2014, 06:58:21 AM »
hi,

 it's almost definitly in your logic that you call twice the same set of logic that leads to a duplicate.

double check your logic accuratly and use the debug flow to go trhough all the steps one by one.

 Bye,

 Jean

Splankton

  • Sr. Member
  • ****
  • Posts: 268
Re: duplicates in an array/hash
« Reply #2 on: June 06, 2014, 02:00:43 PM »
Hi, thanks Jean.  You're right, the index from the target array was removing the picked item, so say index 3 was removed, so the item at index 4, becomes index 3 etc.  Silly error, but I have it working now.