The Dutch National Flag algorithm uses pointers: low, mid, and high. The idea is to partition the array into three regions as you scan.
Everything before low is (red).
Everything between low and mid is (white).
Everything after high is (blue).
Everything between mid and high is unprocessed.
You process elements at mid and swap them into the correct region.