class SplitArray {

  public void splitSwappingIterative(int[] array) {
    if (array == null) {
      throw new IllegalArgumentException("Array passed as parameter can't be null.");
    }

    int left = 0;
    int right = array.length - 1;
    while (left < right) {
      boolean shouldChangeLeft = array[left] >= 0;
      boolean shouldChangeRight = array[right] < 0;
      if (shouldChangeLeft && shouldChangeRight) {
        swap(array, left, right);
        left++;
        right--;
      } else {
        if (!shouldChangeLeft) {
          left++;
        } else if (!shouldChangeRight) {
          right--;
        }
      }
    }
  }

}