// Clone returns a deep copy of the histogram.
// This is useful when combining or taking
// differences of histograms.
439521
func (h *Hist) Clone() *Hist {
	var h2 Hist
	h2 = *h
	c := make([]int64, len(h2.b.counts))
	copy(c, h2.b.counts)
	h2.b.counts = c
	return &h2
}
742191
func (t *TDigest) Clone() *TDigest {
	return &TDigest{
		summary:     t.summary.Clone(),
		compression: t.compression,
		count:       t.count,
		rng:         t.rng,
	}
}
38327
func (mp MultiPoint) Clone() MultiPoint {
	if mp == nil {
		return nil
	}

	points := make([]Point, len(mp))
	copy(points, mp)

	return MultiPoint(points)
}
872465
func (s *Set) Clone() *Set {
	items := make([]string, len(s.items))
	copy(items, s.items)
	return &Set{items}
}
1274247
func (p *PooledCloner) Clone(a, b interface{}) error {
	c := p.pool.Get().(refmt.Cloner)
	err := c.Clone(a, b)
	p.pool.Put(c)
	return err
}
58206
func (m Metric) Clone() Metric {
	clone := make(Metric, len(m))
	for k, v := range m {
		clone[k] = v
	}
	return clone
}
1035892
func (n *node) clone() *node {
	return &node{
		value:    n.value,
		children: n.cloneChildren(),
	}
}
634978
func (s *Spec) Clone() *Spec {
	if s == nil {
		return &Spec{}
	}
	return proto.Clone(s).(*Spec)
}
240765
func (ff *firstRowFunction) Clone() AggregationFunction {
	nf := *ff
	for i, arg := range ff.Args {
		nf.Args[i] = arg.Clone()
	}
	nf.resultMapper = make(aggCtxMapper)
	return &nf
}
1109622
func (p *Path) clone() *Path {
	stack := p.stack
	p.stack = stack[:len(stack):len(stack)]
	return &Path{
		stack:       stack,
		qs:          p.qs,
		baseContext: p.baseContext,
	}
}
906964
func (c *Coordinate) Clone() *Coordinate {
	vec := make([]float64, len(c.Vec))
	copy(vec, c.Vec)
	return &Coordinate{
		Vec:        vec,
		Error:      c.Error,
		Adjustment: c.Adjustment,
		Height:     c.Height,
	}
}
1304387
func Copy(src reflect.Value) reflect.Value {
	d := make(deepcopy)
	return d.copy(src)
}
1084728
func (es *EventStream) Clone() *EventStream {
	patient := new(models.Patient)
	if es.Patient != nil {
		*patient = *es.Patient
	}
	events := make([]Event, len(es.Events))
	copy(events, es.Events)
	return &EventStream{
		Patient: patient,
		Events:  events,
	}
}
664251
func (rb *Bitmap) Clone() *Bitmap {
	ptr := new(Bitmap)
	ptr.highlowcontainer = *rb.highlowcontainer.clone()
	return ptr
}
193661
func (s *ServiceState) Clone() *ServiceState {
	s2 := new(ServiceState)
	*s2 = *s
	return s2
}
11387
func (ds *DiskSource) Clone() Source {
	dsc := &DiskSource{
		BasePath:       ds.BasePath,
		BlockAddresses: ds.BlockAddresses,

		Container: ds.Container,
	}

	if ds.Decompressor != nil {
		dsc.Decompressor = ds.Decompressor.Clone()
	}

	return dsc
}
1233965
func (b *Builder) Clone() *Builder {
	newB := &Builder{
		WriteKey:   b.WriteKey,
		Dataset:    b.Dataset,
		SampleRate: b.SampleRate,
		APIHost:    b.APIHost,
		dynFields:  make([]dynamicField, 0, len(b.dynFields)),
		client:     b.client,
	}
	newB.data = make(map[string]interface{})
	b.lock.RLock()
	defer b.lock.RUnlock()
	for k, v := range b.data {
		newB.data[k] = v
	}
	// copy dynamic metric generators
	b.dynFieldsLock.RLock()
	defer b.dynFieldsLock.RUnlock()
	for _, dynFd := range b.dynFields {
		newB.dynFields = append(newB.dynFields, dynFd)
	}
	return newB
}