// mergeSlice merges a slice of mergers.
970968
func mergeSlice(m1, m2 []merger) []merger {
	r := make([]merger, len(m1), len(m1)+len(m2))
	copy(r, m1)

	m := map[string]struct{}{}
	for _, v2 := range m2 {
		// If we already saw it, just append it because its a
		// duplicate and invalid...
		name := v2.mergerName()
		if _, ok := m[name]; ok {
			r = append(r, v2)
			continue
		}
		m[name] = struct{}{}

		// Find an original to override
		var original merger
		originalIndex := -1
		for i, v := range m1 {
			if v.mergerName() == name {
				originalIndex = i
				original = v
				break
			}
		}

		var v merger
		if original == nil {
			v = v2
		} else {
			v = original.mergerMerge(v2)
		}

		if originalIndex == -1 {
			r = append(r, v)
		} else {
			r[originalIndex] = v
		}
	}

	return r
}
496393
func (v delegatingStrategy) MergeList(diff apply.ListElement) (apply.Result, error) {
	switch diff.GetFieldMergeType() {
	case apply.MergeStrategy:
		return v.merge.MergeList(diff)
	case apply.ReplaceStrategy:
		return v.replace.MergeList(diff)
	case apply.RetainKeysStrategy:
		return v.retainKeys.MergeList(diff)
	default:
		return v.replace.MergeList(diff)
	}
}
567700
func (f *File) GetMergeCells(sheet string) ([]MergeCell, error) {
	var mergeCells []MergeCell
	xlsx, err := f.workSheetReader(sheet)
	if err != nil {
		return mergeCells, err
	}
	if xlsx.MergeCells != nil {
		mergeCells = make([]MergeCell, 0, len(xlsx.MergeCells.Cells))

		for i := range xlsx.MergeCells.Cells {
			ref := xlsx.MergeCells.Cells[i].Ref
			axis := strings.Split(ref, ":")[0]
			val, _ := f.GetCellValue(sheet, axis)
			mergeCells = append(mergeCells, []string{ref, val})
		}
	}

	return mergeCells, err
}
1323800
func (mi *mergeInfo) merge(dst, src pointer) {
	if dst.isNil() {
		panic("proto: nil destination")
	}
	if src.isNil() {
		return // Nothing to do.
	}

	if atomic.LoadInt32(&mi.initialized) == 0 {
		mi.computeMergeInfo()
	}

	for _, fi := range mi.fields {
		sfp := src.offset(fi.field)

		// As an optimization, we can avoid the merge function call cost
		// if we know for sure that the source will have no effect
		// by checking if it is the zero value.
		if unsafeAllowed {
			if fi.isPointer && sfp.getPointer().isNil() { // Could be slice or string
				continue
			}
			if fi.basicWidth > 0 {
				switch {
				case fi.basicWidth == 1 && !*sfp.toBool():
					continue
				case fi.basicWidth == 4 && *sfp.toUint32() == 0:
					continue
				case fi.basicWidth == 8 && *sfp.toUint64() == 0:
					continue
				}
			}
		}

		dfp := dst.offset(fi.field)
		fi.merge(dfp, sfp)
	}

	// TODO: Make this faster?
	out := dst.asPointerTo(mi.typ).Elem()
	in := src.asPointerTo(mi.typ).Elem()
	if emIn, err := extendable(in.Addr().Interface()); err == nil {
		emOut, _ := extendable(out.Addr().Interface())
		mIn, muIn := emIn.extensionsRead()
		if mIn != nil {
			mOut := emOut.extensionsWrite()
			muIn.Lock()
			mergeExtension(mOut, mIn)
			muIn.Unlock()
		}
	}

	if mi.unrecognized.IsValid() {
		if b := *src.offset(mi.unrecognized).toBytes(); len(b) > 0 {
			*dst.offset(mi.unrecognized).toBytes() = append([]byte(nil), b...)
		}
	}
}
1079374
func (s Set) ToSlice() []string {
	ret := make([]string, 0, len(s))
	for k := range s {
		ret = append(ret, k)
	}
	return ret
}
1194745
func (u *UintValue) Merge(onto *uint) {
	if u.v != nil {
		*onto = *(u.v)
	}
}
698587
func mergeMaps(m1, m2 map[string]interface{}) map[string]interface{} {
	for k, v := range m2 {
		if _, ok := m1[k]; !ok {
			m1[k] = v
		}
	}
	return m1
}
129537
func (m Map) Merge(src Map) {
	for k, sv := range src {
		if tv, ok := m[k]; ok {
			m1, ok1 := m.tryConvert(tv)
			m2, ok2 := m.tryConvert(sv)
			if ok1 && ok2 {
				m1.Merge(m2)
			}
		} else {
			if tm, ok := m.tryConvert(sv); ok {
				m[k] = tm
			} else {
				m[k] = sv
			}
		}
	}
}
1305399
func ToInterfaceSlice(slice interface{}) []interface{} {
	v := reflect.ValueOf(slice)
	is := make([]interface{}, 0)
	if v.Kind() == reflect.Slice {
		is = make([]interface{},0 ,v.Len())
		for i := 0; i < v.Len(); i++ {
			is = append(is, v.Index(i).Interface())
		}
	}
	return is
}
169708
func gorocksdb_mergeoperator_partial_merge_multi(idx int, cKey *C.char, cKeyLen C.size_t, cOperands **C.char, cOperandsLen *C.size_t, cNumOperands C.int, cSuccess *C.uchar, cNewValueLen *C.size_t) *C.char {
	key := charToByte(cKey, cKeyLen)
	rawOperands := charSlice(cOperands, cNumOperands)
	operandsLen := sizeSlice(cOperandsLen, cNumOperands)
	operands := make([][]byte, int(cNumOperands))
	for i, len := range operandsLen {
		operands[i] = charToByte(rawOperands[i], len)
	}

	var newValue []byte
	success := true

	merger := mergeOperators.Get(idx).(mergeOperatorWrapper).mergeOperator
	leftOperand := operands[0]
	for i := 1; i < int(cNumOperands); i++ {
		newValue, success = merger.PartialMerge(key, leftOperand, operands[i])
		if !success {
			break
		}
		leftOperand = newValue
	}

	newValueLen := len(newValue)
	*cNewValueLen = C.size_t(newValueLen)
	*cSuccess = boolToChar(success)

	return cByteSlice(newValue)
}
254919
func mergeOptions(options ...map[int]interface{}) map[int]interface{} {
	rst := make(map[int]interface{})

	for _, m := range options {
		for k, v := range m {
			rst[k] = v
		}
	}

	return rst
}
461360
func Merge(mapA map[string]interface{}, mapB map[string]interface{}) map[string]interface{} {
	for k, v := range mapA {
		mapB[k] = v
	}

	return mapB
}
412935
func (set IdentifierSet) ToSlice() []Identifier {
	var s []Identifier
	for v := range set {
		s = append(s, v)
	}
	return s
}
994451
func (c *CMSketch) MergeCMSketch(rc *CMSketch) error {
	if c.depth != rc.depth || c.width != rc.width {
		return errors.New("Dimensions of Count-Min Sketch should be the same")
	}
	if c.topN != nil || rc.topN != nil {
		return errors.New("CMSketch with Top-N does not support merge")
	}
	c.count += rc.count
	for i := range c.table {
		for j := range c.table[i] {
			c.table[i][j] += rc.table[i][j]
		}
	}
	return nil
}
377082
func (h *HyperLogLogPlus) mergeSparse() {
	keys := make(sortableSlice, 0, len(h.tmpSet))
	for k := range h.tmpSet {
		keys = append(keys, k)
	}
	sort.Sort(keys)

	newList := newCompressedList(int(h.m))
	for iter, i := h.sparseList.Iter(), 0; iter.HasNext() || i < len(keys); {
		if !iter.HasNext() {
			newList.Append(keys[i])
			i++
			continue
		}

		if i >= len(keys) {
			newList.Append(iter.Next())
			continue
		}

		x1, x2 := iter.Peek(), keys[i]
		if x1 == x2 {
			newList.Append(iter.Next())
			i++
		} else if x1 > x2 {
			newList.Append(x2)
			i++
		} else {
			newList.Append(iter.Next())
		}
	}

	h.sparseList = newList
	h.tmpSet = set{}

	if uint32(h.sparseList.Len()) > h.m {
		h.toNormal()
	}
}
500327
func (set WordSet) ToSlice() []string {
	var s []string
	for v := range set {
		s = append(s, v)
	}
	return s
}
868928
func (c ConversionFuncs) Merge(other ConversionFuncs) ConversionFuncs {
	merged := NewConversionFuncs()
	for k, v := range c.fns {
		merged.fns[k] = v
	}
	for k, v := range other.fns {
		merged.fns[k] = v
	}
	for k, v := range c.untyped {
		merged.untyped[k] = v
	}
	for k, v := range other.untyped {
		merged.untyped[k] = v
	}
	return merged
}