// Cuts remove the intersect part
976588
func (r Region) Cut(r2 Region) (ret []Region) {
	if r.MidIn(r2.From) {
		ret = append(ret, Region{r.From, r2.From, r.Dir})
	}
	if r.MidIn(r2.To) {
		ret = append(ret, Region{r2.To, r.To, r.Dir})
	}
	if len(ret) == 0 && r2.Size() > 0 && !r2.Cover(r) {
		ret = append(ret, r)
	}
	return
}
924570
func intersect(as, bs [][]byte) [][]byte {
	i := make([][]byte, 0, cmn.MinInt(len(as), len(bs)))
	for _, a := range as {
		for _, b := range bs {
			if bytes.Equal(a, b) {
				i = append(i, a)
			}
		}
	}
	return i
}
564705
func Intersection(a []corev1.ResourceName, b []corev1.ResourceName) []corev1.ResourceName {
	result := make([]corev1.ResourceName, 0, len(a))
	for _, item := range a {
		if Contains(result, item) {
			continue
		}
		if !Contains(b, item) {
			continue
		}
		result = append(result, item)
	}
	sort.Slice(result, func(i, j int) bool { return result[i] < result[j] })
	return result
}
321208
func cutNewLines(s string) string {
	r := strings.SplitN(s, "\r", 2)
	r = strings.SplitN(r[0], "\n", 2)
	return r[0]
}
714782
func (members Members) Intersect(otherMembers Members) Members {
	var res Members
	m := otherMembers.ByID()
	for _, member := range members {
		if _, exists := m[string(member.PKIid)]; exists {
			res = append(res, member)
		}
	}
	return res
}
563585
func SliceRemove(s []string, index int) []string {
	copy(s[index:], s[index+1:])
	// Remove the reference
	s[len(s)-1] = ""
	return s[:len(s)-1]
}
1135519
func Delete(slice []interface{}, i int, n int) []interface{} {
	return append(slice[:i], slice[i+n:]...)
}
224321
func (b *circularRuneBuffer) slice(i, j int) []rune {
	// bounds checking
	if i > j {
		panic("Index out of bounds: slice index i cannot be greater than index j")
	} else if j-i > len(b.runes) {
		panic("Index out of bounds: slice copy length cannot be greater than the original slice length")
	}

	// allocate the slice
	slice := make([]rune, j-i)

	// simple case
	if len(b.runes) < cap(b.runes) {
		copy(slice, b.runes[i:j])
		return slice
	}

	// modulo/circular logic
	i = i % len(b.runes)
	j = j % len(b.runes)

	// if the slice doesn't wrap around the bounary, it's still a simple case
	if i <= j {
		copy(slice, b.runes[i:j])
		return slice
	}

	// copy the 'first' part
	slice_i := b.runes[i:]
	copy(slice, slice_i)

	// copy the 'second' part
	slice_j := b.runes[:j]
	copy(slice[len(slice_i):], slice_j)

	return slice
}
1070955
func (p *Path) Intersects(geometry interface{}) bool {
	var result bool

	switch g := geometry.(type) {
	case Line:
		result = p.IntersectsLine(&g)
	case *Line:
		result = p.IntersectsLine(g)
	case Path:
		result = p.IntersectsPath(&g)
	case *Path:
		result = p.IntersectsPath(g)
	default:
		panic("can only determine intersection with lines and paths")
	}

	return result
}
426786
func InSlice(slice []string, s string) bool {
	for _, ss := range slice {
		if strings.ToLower(s) == strings.ToLower(ss) {
			return true
		}
	}
	return false
}
624723
func intersect(si *topo.ShardInfo, allShards []*topo.ShardInfo) bool {
	for _, shard := range allShards {
		if key.KeyRangesIntersect(si.KeyRange, shard.KeyRange) {
			return true
		}
	}
	return false
}
1246574
func split(s string, c string, cutc bool) (string, string) {
	i := strings.Index(s, c)
	if i < 0 {
		return s, ""
	}
	if cutc {
		return s[:i], s[i+len(c):]
	}
	return s[:i], s[i:]
}
275653
func (me *Dataset) Intersect(other *Dataset) *Dataset {
	ret := me.compoundFromSelf()
	ret.clauses.Compounds = append(ret.clauses.Compounds, Intersect(other.compoundFromSelf()))
	return ret
}
33219
func (s *Set) Intersect(t *Set) *Set {
	ls, lt := len(s.items), len(t.items)
	if lt < ls {
		s, t = t, s
	}
	res := New(ls)

	var offset int
	var ok bool
	for _, v := range s.items {
		if offset, ok = index(t.items, v, offset); ok {
			res.Add(v)
		}
	}
	return res
}
309329
func (t Term) Slice(args ...interface{}) Term {
	var opts = map[string]interface{}{}

	// Look for options map
	if len(args) > 0 {
		if possibleOpts, ok := args[len(args)-1].(SliceOpts); ok {
			opts = possibleOpts.toMap()
			args = args[:len(args)-1]
		}
	}

	return constructMethodTerm(t, "Slice", p.Term_SLICE, args, opts)
}
613259
func (actionSet ActionSet) Intersection(sset ActionSet) ActionSet {
	nset := NewActionSet()
	for k := range actionSet {
		if _, ok := sset[k]; ok {
			nset.Add(k)
		}
	}

	return nset
}
939750
func removeSegments(segments []Segment, toRemove []Segment) []Segment {
	rv := make([]Segment, 0, len(segments)-len(toRemove))
OUTER:
	for _, segment := range segments {
		for _, r := range toRemove {
			if segment == r {
				continue OUTER
			}
		}
		rv = append(rv, segment)
	}
	return rv
}