func (c *CellIndexRangeIterator) nonEmptyPrev() bool {
	for c.prev() {
		if !c.IsEmpty() {
			return true
		}
	}
	if c.IsEmpty() && !c.Done() {
		c.Next()
	}
	return false
}
Prev positions the iterator at the previous entry, and reports whether it was
already positioned at the beginning.
package s2
import (
	"sort"
)
const (
	cellIndexDoneContents = -1
)
type cellIndexNode struct {
	cellID CellID
	label  int32
	parent int32
}
func newCellIndexNode() cellIndexNode {
	return cellIndexNode{
		cellID: 0,
		label:  cellIndexDoneContents,
		parent: -1,
	}
}
type rangeNode struct {
	startID  CellID  
	contents int32   
}
type CellIndexIterator struct {
}
func NewCellIndexIterator(index *CellIndex) *CellIndexIterator {
	return &CellIndexIterator{}
}
type CellIndexRangeIterator struct {
	rangeNodes []rangeNode
	pos        int
	nonEmpty   bool
}
func NewCellIndexRangeIterator(index *CellIndex) *CellIndexRangeIterator {
	return &CellIndexRangeIterator{
		rangeNodes: index.rangeNodes,
	}
}
func NewCellIndexNonEmptyRangeIterator(index *CellIndex) *CellIndexRangeIterator {
	return &CellIndexRangeIterator{
		rangeNodes: index.rangeNodes,
		nonEmpty:   true,
	}
}
func (c *CellIndexRangeIterator) StartID() CellID {
	return c.rangeNodes[c.pos].startID
}
func (c *CellIndexRangeIterator) LimitID() CellID {
	return c.rangeNodes[c.pos+1].startID
}
func (c *CellIndexRangeIterator) IsEmpty() bool {
	return c.rangeNodes[c.pos].contents == cellIndexDoneContents
}
func (c *CellIndexRangeIterator) Begin() {
	c.pos = 0
	for c.nonEmpty && c.IsEmpty() && !c.Done() {
		c.pos++
	}
}
func (c *CellIndexRangeIterator) Prev() bool {
	if c.nonEmpty {
		return c.nonEmptyPrev()
	}
	return c.prev()
}
func (c *CellIndexRangeIterator) prev() bool {
	if c.pos == 0 {
		return false
	}
	c.pos--
	return true
}