// Union will merge all data in another HLL object into this one.
771462
func (h *HLL) Union(other *HLL) error {
	if h.P != other.P {
		return ErrSameP
	}
	if other.format == NORMAL {
		if h.format == SPARSE {
			h.ToNormal()
		}
		for i := uint(0); i < h.m1; i++ {
			if other.registers[i] > h.registers[i] {
				h.registers[i] = other.registers[i]
			}
		}
	} else if h.format == NORMAL && other.format == SPARSE {
		other.mergeSparse()
		for _, value := range other.sparseList.Data {
			index, rho := decodeHash(value, h.P)
			if h.registers[index] < rho {
				h.registers[index] = rho
			}
		}
	} else if h.format == SPARSE && other.format == SPARSE {
		h.mergeSparse()
		other.mergeSparse()
		h.sparseList.Merge(other.sparseList)
		h.checkModeChange()
	}
	return nil
}
71934
func (s Set) Union(other Set) Set {
	ret := make(Set, len(s))
	for k := range s {
		ret[k] = struct{}{}
	}
	for k := range other {
		ret[k] = struct{}{}
	}
	return ret
}
34533
func Union(sets ...*Set) *Set {
	estimateIDs := 0
	estimateGroups := 0

	for _, s := range sets {
		if s == nil {
			continue
		}
		if s.All {
			return &Set{All: true}
		}
		if len(s.IDs) > estimateIDs {
			estimateIDs = len(s.IDs)
		}
		if len(s.Groups) > estimateGroups {
			estimateGroups = len(s.Groups)
		}
	}

	union := &Set{}
	if estimateIDs != 0 {
		union.IDs = make(identSet, estimateIDs)
	}
	if estimateGroups != 0 {
		union.Groups = make(groupSet, estimateGroups)
	}

	for _, s := range sets {
		if s == nil {
			continue
		}
		for ident := range s.IDs {
			union.IDs[ident] = struct{}{}
		}
		for group := range s.Groups {
			union.Groups[group] = struct{}{}
		}
	}

	return union
}
639256
func (e *ErrorRate) Merge(rate *ErrorRate) {
	e.QueryTotal += rate.QueryTotal
	e.ErrorTotal += rate.ErrorTotal
}
720748
func (s *StringValue) Merge(onto *string) {
	if s.v != nil {
		*onto = *(s.v)
	}
}
442939
func (g1 *Virtual) union(g2 *Virtual, cost bool) *Virtual {
	switch {
	case g1.order == 0:
		if cost {
			return g2
		}
		return g2.AddCost(0)
	case g2.order == 0:
		if cost {
			return g1
		}
		return g1.AddCost(0)
	}

	newCost := zero
	if cost {
		newCost = func(v, w int) int64 {
			if g2.edge(v, w) && !g1.edge(v, w) {
				return g2.cost(v, w)
			}
			return g1.cost(v, w)
		}
	}
	var res *Virtual
	switch {
	case g1.order == g2.order:
		res = generic(g1.order, newCost, func(v, w int) bool {
			return g1.edge(v, w) || g2.edge(v, w)
		})
	case g1.order < g2.order:
		res = generic(g2.order, newCost, func(v, w int) bool {
			return v < g1.order && w < g1.order && g1.edge(v, w) || g2.edge(v, w)
		})
	default:
		res = generic(g1.order, newCost, func(v, w int) bool {
			return v < g2.order && w < g2.order && g2.edge(v, w) || g1.edge(v, w)
		})
	}

	res.visit = func(v int, a int, do func(w int, c int64) bool) (aborted bool) {
		next := 0
		if v < g1.order && g1.visit(v, a, func(w int, c int64) (skip bool) {
			// First all neighbors from g2 that are less than w...
			if next != w && v < g2.order && a <= w {
				if more := false; g2.visit(v, max(next, a), func(w0 int, c0 int64) (skip bool) {
					if w0 >= w {
						more, skip = true, true
						return
					}
					if cost {
						return do(w0, c0)
					}
					return do(w0, 0)
				}) && !more {
					return true
				}
			}
			// ...then w.
			switch {
			case cost && do(w, c):
				return true
			case !cost && do(w, 0):
				return true
			}
			next = w + 1
			return
		}) {
			return true
		}
		// When done with g1, produce any leftovers from g2.
		return v < g2.order && g2.visit(v, max(next, a), func(w int, c int64) (skip bool) {
			if cost {
				return do(w, c)
			}
			return do(w, 0)
		})
	}
	return res
}
1176805
func Merge(values ...Value) (Value, error) {
	var args []string
	for _, value := range values {
		args = append(args, value.String())
	}
	return Parse(args...)
}
863790
func (h *EssentialHeader) Merge(h2 *EssentialHeader) {
	if h2.AgreementPartyUInfo.Len() != 0 {
		h.AgreementPartyUInfo = h2.AgreementPartyUInfo
	}

	if h2.AgreementPartyVInfo.Len() != 0 {
		h.AgreementPartyVInfo = h2.AgreementPartyVInfo
	}

	if h2.Algorithm != "" {
		h.Algorithm = h2.Algorithm
	}

	if h2.ContentEncryption != "" {
		h.ContentEncryption = h2.ContentEncryption
	}

	if h2.ContentType != "" {
		h.ContentType = h2.ContentType
	}

	if h2.Compression != "" {
		h.Compression = h2.Compression
	}

	if h2.Critical != nil {
		h.Critical = h2.Critical
	}

	if h2.EphemeralPublicKey != nil {
		h.EphemeralPublicKey = h2.EphemeralPublicKey
	}

	if h2.Jwk != nil {
		h.Jwk = h2.Jwk
	}

	if h2.JwkSetURL != nil {
		h.JwkSetURL = h2.JwkSetURL
	}

	if h2.KeyID != "" {
		h.KeyID = h2.KeyID
	}

	if h2.Type != "" {
		h.Type = h2.Type
	}

	if h2.X509Url != nil {
		h.X509Url = h2.X509Url
	}

	if h2.X509CertChain != nil {
		h.X509CertChain = h2.X509CertChain
	}

	if h2.X509CertThumbprint != "" {
		h.X509CertThumbprint = h2.X509CertThumbprint
	}

	if h2.X509CertThumbprintS256 != "" {
		h.X509CertThumbprintS256 = h2.X509CertThumbprintS256
	}
}
294246
func (set WordSet) Union(other WordSet) WordSet {
	unionedSet := NewWordSet()

	for elem := range set {
		unionedSet.Add(elem)
	}
	for elem := range other {
		unionedSet.Add(elem)
	}
	return unionedSet
}
921468
func (w *WindowedHistogram) Merge() *Histogram {
	w.m.Reset()
	for _, h := range w.h {
		w.m.Merge(&h)
	}
	return w.m
}
468854
func (s1 Int) Union(s2 Int) Int {
	result := NewInt()
	for key := range s1 {
		result.Insert(key)
	}
	for key := range s2 {
		result.Insert(key)
	}
	return result
}
1219460
func (h Dense) Merge(g Dense) error {
	if len(h) != len(g) {
		return errors.New("size mismatch")
	}
	for i := 0; i < len(h); i += 3 {
		x0, x1, x2 := h[i], h[i+1], h[i+2]
		y0, y1, y2 := g[i], g[i+1], g[i+2]
		const m = ^byte(3)
		xH0, xH1, xH2 := x0&m, x1&m, x2&m
		xL0, xL1, xL2 := x0&^m, x1&^m, x2&^m
		yH0, yH1, yH2 := y0&m, y1&m, y2&m
		yL0, yL1, yL2 := y0&^m, y1&^m, y2&^m
		var r0, r1, r2 byte
		if xH0 > yH0 {
			r0 = xH0
		} else {
			r0 = yH0
		}
		if xH1 > yH1 {
			r1 = xH1
		} else {
			r1 = yH1
		}
		if xH2 > yH2 {
			r2 = xH2
		} else {
			r2 = yH2
		}
		xx := xL0<<4 ^ xL1<<2 ^ xL2
		yy := yL0<<4 ^ yL1<<2 ^ yL2
		if xx > yy {
			h[i] = r0 ^ xL0
			h[i+1] = r1 ^ xL1
			h[i+2] = r2 ^ xL2
		} else {
			h[i] = r0 ^ yL0
			h[i+1] = r1 ^ yL1
			h[i+2] = r2 ^ yL2
		}
	}
	return nil
}
1239940
func (s *Set) Union(t *Set) *Set {
	ls, lt := len(s.items), len(t.items)
	if lt < ls {
		s, t = t, s
	}

	res := t.Clone()
	for _, v := range s.items {
		res.Add(v)
	}
	return res
}
1104517
func (s1 Int64) Union(s2 Int64) Int64 {
	result := NewInt64()
	for key := range s1 {
		result.Insert(key)
	}
	for key := range s2 {
		result.Insert(key)
	}
	return result
}
644953
func (i Interval) Union(other Interval) Interval {
	if i.IsEmpty() {
		return other
	}
	if other.IsEmpty() {
		return i
	}
	return Interval{math.Min(i.Lo, other.Lo), math.Max(i.Hi, other.Hi)}
}
570662
func (h *Histogram) Merge(from *Histogram) (dropped int64) {
	i := from.rIterator()
	for i.next() {
		v := i.valueFromIdx
		c := i.countAtIdx

		if h.RecordValues(v, c) != nil {
			dropped += c
		}
	}

	return
}
534416
func (p *trie) merge(m matcher) (matcher, error) {
	other, ok := m.(*trie)
	if !ok {
		return nil, fmt.Errorf("Can't merge %T and %T", p, m)
	}
	mapper := p.mapper.equivalent(other.mapper)
	if mapper == nil {
		return nil, fmt.Errorf("Can't merge %T and %T", p, m)
	}

	root, err := p.root.merge(other.root)
	if err != nil {
		return nil, err
	}
	return &trie{root: root, mapper: mapper}, nil
}