normalizeIndex method

void normalizeIndex()

puts current index back into range of nodes list values.

Implementation

void normalizeIndex() {
  if (currentIndex < 0) {
    currentIndex = 0;
  } else if (currentIndex >= nodes.length) {
    currentIndex = nodes.length - 1;
  }
}