playMaker
Home
Store
Showcase
Tutorials
Forums
Manual
Wiki
About Us
Playmaker Forum
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Join our
Discord Channel
Home
Help
Search
Login
Register
Playmaker Forum
»
PlayMaker Help & Tips
»
PlayMaker Help
(Moderator:
600
) »
duplicates in an array/hash[SOLVED]
« previous
next »
Print
Pages: [
1
]
Go Down
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
»
Logged
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
Logged
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.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
Playmaker Forum
»
PlayMaker Help & Tips
»
PlayMaker Help
(Moderator:
600
) »
duplicates in an array/hash[SOLVED]