// Subtract removes the intersection between r and other
// from r, possibly splitting r into two smaller ranges.
507698
func (r Range) Subtract(other Range) []Range {
	if !r.Overlaps(other) {
		return []Range{r}
	}
	if other.Contains(r) {
		return nil
	}
	var res []Range
	left := Range{r.Start, other.Start}
	right := Range{other.End, r.End}
	if r.Contains(other) {
		if !left.IsEmpty() {
			res = append(res, left)
		}
		if !right.IsEmpty() {
			res = append(res, right)
		}
		return res
	}
	if !r.Start.After(other.Start) {
		if !left.IsEmpty() {
			res = append(res, left)
		}
		return res
	}
	if !right.IsEmpty() {
		res = append(res, right)
	}
	return res
}
74315
func (s *SyncedSet) Intersect(other *SyncedSet) *SyncedSet {
	newSet := NewSyncedSet()
	for k := range s.set {
		if other.Contains(k) {
			newSet.Add(k)
		}
	}
	return &newSet
}
42112
func (t TimeRange) Intersect(other TimeRange) TimeRange {
	if !other.Min.IsZero() {
		if t.Min.IsZero() || other.Min.After(t.Min) {
			t.Min = other.Min
		}
	}
	if !other.Max.IsZero() {
		if t.Max.IsZero() || other.Max.Before(t.Max) {
			t.Max = other.Max
		}
	}
	return t
}
100612
func (m *Money) Subtract(om *Money) (*Money, error) {
	if err := m.assertSameCurrency(om); err != nil {
		return nil, err
	}

	return &Money{amount: mutate.calc.subtract(m.amount, om.amount), currency: m.currency}, nil
}
1155114
func (a admissionRequirementList) subtract(pods ...*v1.Pod) admissionRequirementList {
	newList := []*admissionRequirement{}
	for _, req := range a {
		newQuantity := req.quantity
		for _, pod := range pods {
			newQuantity -= resource.GetResourceRequest(pod, req.resourceName)
		}
		if newQuantity > 0 {
			newList = append(newList, &admissionRequirement{
				resourceName: req.resourceName,
				quantity:     newQuantity,
			})
		}
	}
	return newList
}
1287591
func (s *set) Intersect(other Set) Set {
	o := other.(*set)
	n, m := s.Len(), o.Len()
	ss := s
	so := o
	if m < n {
		ss = o
		so = s
		n = m
	}

	r := newset(n)
	ss.Foreach(func(x *Term) {
		if so.Contains(x) {
			r.Add(x)
		}
	})
	return r
}
1058528
func (s1 Int32) Intersection(s2 Int32) Int32 {
	var walk, other Int32
	result := NewInt32()
	if s1.Len() < s2.Len() {
		walk = s1
		other = s2
	} else {
		walk = s2
		other = s1
	}
	for key := range walk {
		if other.Has(key) {
			result.Insert(key)
		}
	}
	return result
}
770583
func (u Vec) Sub(v Vec) Vec {
	return Vec{
		u.X - v.X,
		u.Y - v.Y,
	}
}
1366404
func (p *Point) Subtract(point *Point) *Point {
	p[0] -= point[0]
	p[1] -= point[1]

	return p
}
1276313
func (resources Resources) Minus(that ...Resource) Resources {
	x := resources.Clone()
	return x.Subtract(that...)
}
616699
func (term Range) Intersection(other Range) (intersect Range) {
	// If either range is empty then the intersection is empty
	if term.IsEmpty() || other.IsEmpty() {
		intersect = Empty()
		return
	}

	if other.Start.Within(term) {
		intersect.Start = other.Start
	} else if term.Start.Within(other) {
		intersect.Start = term.Start
	} else if term.Start.IsZero() && other.Start.IsZero() {
		// Unbounded
	} else {
		intersect = Empty()
		return
	}

	if other.End.Within(term) {
		intersect.End = other.End
	} else if term.End.Within(other) {
		intersect.End = term.End
	} else if term.End.IsZero() && other.End.IsZero() {
		// Unbounded
	} else {
		intersect = Empty()
		return
	}
	return
}
929799
func Subtract(vs ReaderWriter, vsOther Iterable) error {
	return vsOther.IterateValidators(func(id crypto.Addressable, power *big.Int) error {
		return SubtractPower(vs, id.GetPublicKey(), power)
	})
}
613904
func (r Range) Intersect(other Range) (Range, bool) {
	if !r.Overlaps(other) {
		return Range{}, false
	}
	newRange := r
	if newRange.Start.Before(other.Start) {
		newRange.Start = other.Start
	}
	if newRange.End.After(other.End) {
		newRange.End = other.End
	}
	return newRange, true
}
601269
func (vec *T) Sub(v *T) *T {
	vec[0] -= v[0]
	vec[1] -= v[1]
	return vec
}
262258
func (p *Point) SubtractScalar(s float32) *Point {
	p.AddScalar(-s)
	return p
}
128316
func (c ChordAngle) Sub(other ChordAngle) ChordAngle {
	if other == 0 {
		return c
	}
	if c <= other {
		return 0
	}
	x := float64(c * (1 - 0.25*other))
	y := float64(other * (1 - 0.25*c))
	return ChordAngle(math.Max(0.0, x+y-2*math.Sqrt(x*y)))
}
454551
func Intersection(set1, set2 Interface, sets ...Interface) Interface {
	all := Union(set1, set2, sets...)
	result := Union(set1, set2, sets...)

	all.Each(func(item interface{}) bool {
		if !set1.Has(item) || !set2.Has(item) {
			result.Remove(item)
		}

		for _, set := range sets {
			if !set.Has(item) {
				result.Remove(item)
			}
		}
		return true
	})
	return result
}