in reply to Re: Re: Hash key counting
in thread Hash key counting
Then it is quite likely that you a missing one key value (as has been hinted at several places in this thread). What keys are in the hash when this code isn't working? If the keys are, for example, 1, 2, 3, 5, 6, and 7, then you have 6 keys and you will use "7" as your next key (since "4" is missing). Such would explain your problem.
This is part of why so many have complained about not understanding your code. Part of your code assumes that all keys from 1 through N will be present (and no others) which means an array would be a more appropriate data structure (and wouldn't be susceptible to this type of bug). And you have yet to explain how you use this hash elsewhere, so we are forced to guess why you'd choose what appears to be a very poorly fitting solution, so we can't help much with fixing it.
- tye
|
|---|