Skip to content

Instantly share code, notes, and snippets.

@Tomyail
Created January 10, 2013 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tomyail/4501749 to your computer and use it in GitHub Desktop.
Save Tomyail/4501749 to your computer and use it in GitHub Desktop.
(i%3+3)%3 i是任意整型,3是数组长度,得到的结果都是一个对于该数组合法的索引
public function getLegalIndexFromArray(index,arrayLength):int
{
return (index%arrayLength+arrayLength)%arrayLength;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment