Ejemplo n.º 1
0
// Remove elements >= rightIter that make the curve concave after
// adding thisElem.
func (f *frontier) maybeRemoveRightElements(
	thisElem frontierItem, rightIter rbtree.Iterator) {
	if rightIter.Limit() {
		return
	}

	ti := rightIter.Next()
	for !ti.Limit() && !isConcave(thisElem, getItem(rightIter), getItem(ti)) {
		tmp := rightIter
		rightIter = ti
		ti = ti.Next()
		f.tree.DeleteWithIterator(tmp)
	}
}
Ejemplo n.º 2
0
// Remove elements <= leftIter that make the curve concave after
// adding thisElem.
func (f *frontier) maybeRemoveLeftElements(
	thisElem frontierItem, leftIter rbtree.Iterator) {
	if leftIter.NegativeLimit() {
		return
	}

	if getItem(leftIter).y >= thisElem.y {
		tmp := leftIter
		leftIter = leftIter.Prev()
		f.tree.DeleteWithIterator(tmp)
	}

	if leftIter.NegativeLimit() {
		return
	}
	ti := leftIter.Prev()

	for !ti.NegativeLimit() && !isConcave(getItem(ti), getItem(leftIter), thisElem) {
		tmp := leftIter
		leftIter = ti
		ti = ti.Prev()
		f.tree.DeleteWithIterator(tmp)
	}
}
Ejemplo n.º 3
0
func getItem(iter rbtree.Iterator) frontierItem {
	return iter.Item().(frontierItem)
}