Is there a simple algorithm to iterate over all the elements in an array given a constant stride?

I am currently using a circularly linked list to popluate a temporary array with indecies to of the actual array by traversing through the linked list (stride) and then removing the node from the linked list and placing the node's value into the temporary array. this repeats until there is no more links left.

This temporary array of indecies is then used to popluate an new array with the values from the original array given the temporary array's values as indecies.

This method works, however is it very slow... is there a faster way? i.e. is there a mathematical formula i can use to generate the next index in the sequence?

Ah ha! I thought it must be more complex than that Now thats a real humdinger of a problem. Have you considered storing a wrapping object in the array instead of the actual object with a indicator as to whether it's been used this time (obviously it wouldn't be thread safe).

Then once you've used an item mark it as used (like taking it out of temporary list) and then cycle through every element in your array counting up unused items until you reach your stride.

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org