func (f *FixedSizeRingBuf) Prevpos(from int) int {
	if from >= f.N || from < 0 {
		return -2
	}
	if f.Readable == 0 {
		return -1
	}
	if from == f.Beg {
		return -1
	}
	a0, a1, b0, b1 := f.LegalPos()
	switch {
	case from == a0:
		return -1
	case from > a0 && from <= a1:
		return from - 1
	case from == b0:
		return a1
	case from > b0 && from <= b1:
		return from - 1
	}
	return -1
}
func (f *FixedSizeRingBuf) Prevpos(from int) int {
	if from >= f.N || from < 0 {
		return -2
	}
	if f.Readable == 0 {
		return -1
	}
	if from == f.Beg {
		return -1
	}
	a0, a1, b0, b1 := f.LegalPos()
	switch {
	case from == a0:
		return -1
	case from > a0 && from <= a1:
		return from - 1
	case from == b0:
		return a1
	case from > b0 && from <= b1:
		return from - 1
	}
	return -1
}
func ( f * FixedSizeRingBuf ) Prevpos ( from int ) int { if from >= f . N || from < 0 { return - 2 } if f . Readable == 0 { return - 1 } if from == f . Beg { return - 1 } a0 , a1 , b0 , b1 := f . LegalPos ( ) switch { case from == a0 : return - 1 case from > a0 && from <= a1 : return from - 1 case from == b0 : return a1 case from > b0 && from <= b1 : return from - 1 } return - 1 }
// Prevpos returns the index of the element before
// from, or -1 if no more and from is the
// first in the ring. Returns -2 on bad
// from position.
Prevpos returns the index of the element before from or - 1 if no more and from is the first in the ring . Returns - 2 on bad from position .