func (f *FixedSizeRingBuf) Nextpos(from int) int {
	if from >= f.N || from < 0 {
		return -2
	}
	if f.Readable == 0 {
		return -1
	}

	last := f.Last()
	if from == last {
		return -1
	}
	a0, a1, b0, b1 := f.LegalPos()
	switch {
	case from >= a0 && from < a1:
		return from + 1
	case from == a1:
		return b0 // can be -1
	case from >= b0 && from < b1:
		return from + 1
	case from == b1:
		return -1
	}
	return -1
}
func (f *FixedSizeRingBuf) Nextpos(from int) int {
	if from >= f.N || from < 0 {
		return -2
	}
	if f.Readable == 0 {
		return -1
	}

	last := f.Last()
	if from == last {
		return -1
	}
	a0, a1, b0, b1 := f.LegalPos()
	switch {
	case from >= a0 && from < a1:
		return from + 1
	case from == a1:
		return b0 
	case from >= b0 && from < b1:
		return from + 1
	case from == b1:
		return -1
	}
	return -1
}
func ( f * FixedSizeRingBuf ) Nextpos ( from int ) int { if from >= f . N || from < 0 { return - 2 } if f . Readable == 0 { return - 1 } last := f . Last ( ) if from == last { return - 1 } a0 , a1 , b0 , b1 := f . LegalPos ( ) switch { case from >= a0 && from < a1 : return from + 1 case from == a1 : return b0 // can be -1 case from >= b0 && from < b1 : return from + 1 case from == b1 : return - 1 } return - 1 }
// Next returns the index of the element after
// from, or -1 if no more. returns -2 if erroneous
// input (bad from).
Next returns the index of the element after from or - 1 if no more . returns - 2 if erroneous input ( bad from ) .