ranges/ranges.go
func (l *InclusiveRanges) Index(value int) int {
	var idx, n int

	for _, b := range l.blocks {
		// If the value is within the current block
		// then return the local index, offset by the
		// number of previous values we have tracked
		if idx = b.Index(value); idx >= 0 {
			return idx + n
		}
		// Update the offset for the values we have seen
		n += b.Len()
	}

	// The previous loop ended in error
	return -1
}
func (l *InclusiveRanges) Index(value int) int {
	var idx, n int

	for _, b := range l.blocks {
		// If the value is within the current block
		// then return the local index, offset by the
		// number of previous values we have tracked
		if idx = b.Index(value); idx >= 0 {
			return idx + n
		}
		// Update the offset for the values we have seen
		n += b.Len()
	}

	// The previous loop ended in error
	return -1
}
// Index returns the 0-based index of the first occurrence
// of the given value, within the range.
// If the value does not exist in the range, a
// value of -1 will be returned.