Change algorithm increment. Copied from Java ArrayList