Circular buffer in swift