Transform an index into an offset.

The method takes care of the initial gap and the possible wrapping.

REQUIRE: 0 <= index and index < length

Property definitions

core $ CircularArray :: offset
	# Transform an index into an offset.
	#
	# The method takes care of the initial gap and the possible wrapping.
	#
	# REQUIRE: `0 <= index and index < length`
	private fun offset(index: Int): Int
	do
		assert index >= 0
		var head = self._head
		var tail = self._tail
		var offset = head + index

		if head > tail then
			# Two parts
			var capacity = native.length
			if offset < capacity then
				return offset
			end
			offset -= capacity
		end

		assert offset <= tail
		return offset
	end
lib/core/collection/circular_array.nit:64,2--87,4