While having a loop
with 0 1 2 3 4 5 0 1 2 3 ... there are two directions for instance from number 4 forwarding 4 5 0 1 2 3 ... and backward 4 3 2 1 0 5 ... . How would the if algorithm for detecting of forwarding or backward look like if values are like actual 2 next 3, or actual 5 next 0.
I'm looking for a simple if that will check
if (actual > next && ?jump from last/first?) {
forwarding
} else {
backward
}
Any ideas how to detect forward or backward?