// GetIntersecting gets all documents where the given geometry object intersects
// the geometry object of the requested geospatial index.
178826
func (t Term) GetIntersecting(args interface{}, optArgs ...GetIntersectingOpts) Term {
	opts := map[string]interface{}{}
	if len(optArgs) >= 1 {
		opts = optArgs[0].toMap()
	}

	return constructMethodTerm(t, "GetIntersecting", p.Term_GET_INTERSECTING, []interface{}{args}, opts)
}
1054844
func intersectInterval16s(a, b interval16) (res interval16, isEmpty bool) {
	if !haveOverlap16(a, b) {
		isEmpty = true
		return
	}
	if b.start > a.start {
		res.start = b.start
	} else {
		res.start = a.start
	}

	bEnd := b.last()
	aEnd := a.last()
	var resEnd uint16

	if bEnd < aEnd {
		resEnd = bEnd
	} else {
		resEnd = aEnd
	}
	res.length = resEnd - res.start
	return
}
1074755
func (r Rect) Intersects(other Rect) bool {
	return r.Lat.Intersects(other.Lat) && r.Lng.Intersects(other.Lng)
}
20044
func (ns *Namespace) Intersect(l1, l2 interface{}) (interface{}, error) {
	if l1 == nil || l2 == nil {
		return make([]interface{}, 0), nil
	}

	var ins *intersector

	l1v := reflect.ValueOf(l1)
	l2v := reflect.ValueOf(l2)

	switch l1v.Kind() {
	case reflect.Array, reflect.Slice:
		ins = &intersector{r: reflect.MakeSlice(l1v.Type(), 0, 0), seen: make(map[interface{}]bool)}
		switch l2v.Kind() {
		case reflect.Array, reflect.Slice:
			for i := 0; i < l1v.Len(); i++ {
				l1vv := l1v.Index(i)
				if !l1vv.Type().Comparable() {
					return make([]interface{}, 0), errors.New("intersect does not support slices or arrays of uncomparable types")
				}

				for j := 0; j < l2v.Len(); j++ {
					l2vv := l2v.Index(j)
					if !l2vv.Type().Comparable() {
						return make([]interface{}, 0), errors.New("intersect does not support slices or arrays of uncomparable types")
					}

					ins.handleValuePair(l1vv, l2vv)
				}
			}
			return ins.r.Interface(), nil
		default:
			return nil, errors.New("can't iterate over " + reflect.ValueOf(l2).Type().String())
		}
	default:
		return nil, errors.New("can't iterate over " + reflect.ValueOf(l1).Type().String())
	}
}
808987
func (s *Selection) IndexOfSelection(sel *Selection) int {
	if sel != nil && len(sel.Nodes) > 0 {
		return indexInSlice(s.Nodes, sel.Nodes[0])
	}
	return -1
}
968146
func (c *CrossingEdgeQuery) computeCellsIntersected(pcell *PaddedCell, edgeBound r2.Rect) {

	c.iter.seek(pcell.id.RangeMin())
	if c.iter.Done() || c.iter.CellID() > pcell.id.RangeMax() {
		// The index does not contain pcell or any of its descendants.
		return
	}
	if c.iter.CellID() == pcell.id {
		// The index contains this cell exactly.
		c.cells = append(c.cells, c.iter.IndexCell())
		return
	}

	// Otherwise, split the edge among the four children of pcell.
	center := pcell.Middle().Lo()

	if edgeBound.X.Hi < center.X {
		// Edge is entirely contained in the two left children.
		c.clipVAxis(edgeBound, center.Y, 0, pcell)
		return
	} else if edgeBound.X.Lo >= center.X {
		// Edge is entirely contained in the two right children.
		c.clipVAxis(edgeBound, center.Y, 1, pcell)
		return
	}

	childBounds := c.splitUBound(edgeBound, center.X)
	if edgeBound.Y.Hi < center.Y {
		// Edge is entirely contained in the two lower children.
		c.computeCellsIntersected(PaddedCellFromParentIJ(pcell, 0, 0), childBounds[0])
		c.computeCellsIntersected(PaddedCellFromParentIJ(pcell, 1, 0), childBounds[1])
	} else if edgeBound.Y.Lo >= center.Y {
		// Edge is entirely contained in the two upper children.
		c.computeCellsIntersected(PaddedCellFromParentIJ(pcell, 0, 1), childBounds[0])
		c.computeCellsIntersected(PaddedCellFromParentIJ(pcell, 1, 1), childBounds[1])
	} else {
		// The edge bound spans all four children. The edge itself intersects
		// at most three children (since no padding is being used).
		c.clipVAxis(childBounds[0], center.Y, 0, pcell)
		c.clipVAxis(childBounds[1], center.Y, 1, pcell)
	}
}
99118
func (c *Menu) GetSelectedOption() *MenuOption {
	idx := c.GetSelectedIndex()
	if idx != -1 {
		return &c.options[idx]
	}
	return nil
}
507869
func rayIntersect(p, s, e orb.Point) (intersects, on bool) {
	if s[0] > e[0] {
		s, e = e, s
	}

	if p[0] == s[0] {
		if p[1] == s[1] {
			// p == start
			return false, true
		} else if s[0] == e[0] {
			// vertical segment (s -> e)
			// return true if within the line, check to see if start or end is greater.
			if s[1] > e[1] && s[1] >= p[1] && p[1] >= e[1] {
				return false, true
			}

			if e[1] > s[1] && e[1] >= p[1] && p[1] >= s[1] {
				return false, true
			}
		}

		// Move the y coordinate to deal with degenerate case
		p[0] = math.Nextafter(p[0], math.Inf(1))
	} else if p[0] == e[0] {
		if p[1] == e[1] {
			// matching the end point
			return false, true
		}

		p[0] = math.Nextafter(p[0], math.Inf(1))
	}

	if p[0] < s[0] || p[0] > e[0] {
		return false, false
	}

	if s[1] > e[1] {
		if p[1] > s[1] {
			return false, false
		} else if p[1] < e[1] {
			return true, false
		}
	} else {
		if p[1] > e[1] {
			return false, false
		} else if p[1] < s[1] {
			return true, false
		}
	}

	rs := (p[1] - s[1]) / (p[0] - s[0])
	ds := (e[1] - s[1]) / (e[0] - s[0])

	if rs == ds {
		return false, true
	}

	return rs <= ds, false
}
159745
func (o *InsideBoundingBoxOption) Get() ([][4]float64, string) {
	if o == nil {
		return nil, ""
	}
	return o.boxes, o.coordinates
}
1241227
func (r Rect) InteriorIntersects(other Rect) bool {
	return r.X.InteriorIntersects(other.X) && r.Y.InteriorIntersects(other.Y)
}
2362
func naiveSelectionFinding(data Interface, k int) {
	smallestIndices := make([]int, k)
	for i := 0; i < k; i++ {
		smallestIndices[i] = i
	}
	resetLargestIndex(smallestIndices, data)

	for i := k; i < data.Len(); i++ {
		if data.Less(i, smallestIndices[k-1]) {
			smallestIndices[k-1] = i
			resetLargestIndex(smallestIndices, data)
		}
	}

	insertionSort(IntSlice(smallestIndices), 0, k)
	for i := 0; i < k; i++ {
		data.Swap(i, smallestIndices[i])
	}
}
555288
func (r *Adaptor) GetSpiConnection(busNum, chipNum, mode, bits int, maxSpeed int64) (connection spi.Connection, err error) {
	r.mutex.Lock()
	defer r.mutex.Unlock()

	if (busNum < 0) || (busNum > 1) {
		return nil, fmt.Errorf("Bus number %d out of range", busNum)
	}

	if r.spiDevices[busNum] == nil {
		r.spiDevices[busNum], err = spi.GetSpiConnection(busNum, chipNum, mode, bits, maxSpeed)
	}

	return r.spiDevices[busNum], err
}
1334804
func (a *Rect) HasIntersection(b *Rect) bool {
	if a == nil || b == nil {
		return false
	}

	// Special case for empty rects
	if a.Empty() || b.Empty() {
		return false
	}

	if a.X >= b.X+b.W || a.X+a.W <= b.X || a.Y >= b.Y+b.H || a.Y+a.H <= b.Y {
		return false
	}

	return true
}
34718
func GetOperand(p plannercore.LogicalPlan) Operand {
	switch p.(type) {
	case *plannercore.LogicalJoin:
		return OperandJoin
	case *plannercore.LogicalAggregation:
		return OperandAggregation
	case *plannercore.LogicalProjection:
		return OperandProjection
	case *plannercore.LogicalSelection:
		return OperandSelection
	case *plannercore.LogicalApply:
		return OperandApply
	case *plannercore.LogicalMaxOneRow:
		return OperandMaxOneRow
	case *plannercore.LogicalTableDual:
		return OperandTableDual
	case *plannercore.DataSource:
		return OperandDataSource
	case *plannercore.LogicalUnionScan:
		return OperandUnionScan
	case *plannercore.LogicalUnionAll:
		return OperandUnionAll
	case *plannercore.LogicalSort:
		return OperandSort
	case *plannercore.LogicalTopN:
		return OperandTopN
	case *plannercore.LogicalLock:
		return OperandLock
	case *plannercore.LogicalLimit:
		return OperandLimit
	default:
		return OperandUnsupported
	}
}
1082231
func (c Cap) InteriorIntersects(other Cap) bool {
	// Make sure this cap has an interior and the other cap is non-empty.
	if c.height <= zeroHeight || other.IsEmpty() {
		return false
	}

	return c.Radius()+other.Radius() > c.center.Distance(other.center)
}
1052881
func (t Term) Intersects(args ...interface{}) Term {
	return constructMethodTerm(t, "Intersects", p.Term_INTERSECTS, args, map[string]interface{}{})
}
267361
func (l *Loop) Intersects(o *Loop) bool {
	// Given two loops, A and B, A.Intersects(B) if and only if !A.Complement().Contains(B).
	//
	// This code is similar to Contains, but is optimized for the case
	// where both loops enclose less than half of the sphere.
	if !l.bound.Intersects(o.bound) {
		return false
	}

	// Check whether there are any edge crossings, and also check the loop
	// relationship at any shared vertices.
	relation := &intersectsRelation{}
	if hasCrossingRelation(l, o, relation) {
		return true
	}
	if relation.foundSharedVertex {
		return false
	}

	// Since there are no edge intersections or shared vertices, the loops
	// intersect only if A contains B, B contains A, or the two loops contain
	// each other's boundaries.  These checks are usually cheap because of the
	// bounding box preconditions.  Note that neither loop is empty (because of
	// the bounding box check above), so it is safe to access vertex(0).

	// Check whether A contains B, or A and B contain each other's boundaries.
	// (Note that A contains all the vertices of B in either case.)
	if l.subregionBound.Contains(o.bound) || l.bound.Union(o.bound).IsFull() {
		if l.ContainsPoint(o.Vertex(0)) {
			return true
		}
	}
	// Check whether B contains A.
	if o.subregionBound.Contains(l.bound) {
		if o.ContainsPoint(l.Vertex(0)) {
			return true
		}
	}
	return false
}