// NewWithData creates a new reference where data is passed from the Get
// function to the initializer. This is useful for refreshing the reference
// with dynamic data.
429069
func NewWithData(initializer InitializerWithData, opts ...options.Opt) *Reference {
	lazyRef := &Reference{
		params: params{
			initialInit: InitOnFirstAccess,
		},
		initializer: initializer,
	}

	options.Apply(lazyRef, opts)

	if lazyRef.expirationProvider != nil {
		// This is an expiring reference. After the initializer is
		// called, set a timer that will call the expiration handler.
		initializer := lazyRef.initializer
		initialExpiration := lazyRef.expirationProvider()
		lazyRef.initializer = func(data interface{}) (interface{}, error) {
			value, err := initializer(data)
			if err == nil {
				lazyRef.ensureTimerStarted(initialExpiration)
			}
			return value, err
		}

		lazyRef.closech = make(chan bool, 1)

		if lazyRef.expirationHandler == nil {
			if lazyRef.expiryType == Refreshing {
				lazyRef.expirationHandler = lazyRef.refreshValue
			} else {
				lazyRef.expirationHandler = lazyRef.resetValue
			}
		}

		if lazyRef.initialInit >= 0 {
			lazyRef.ensureTimerStarted(lazyRef.initialInit)
		}
	}

	return lazyRef
}
1125603
func (s *RawMessage) SetData(v []byte) *RawMessage {
	s.Data = v
	return s
}
784857
func NewMergingFromData(d *MergingDigestData) *MergingDigest {
	td := &MergingDigest{
		compression:   d.Compression,
		mainCentroids: d.MainCentroids,
		tempCentroids: make([]Centroid, 0, estimateTempBuffer(d.Compression)),
		min:           d.Min,
		max:           d.Max,
		reciprocalSum: d.ReciprocalSum,
	}

	// Initialize the weight to the sum of the weights of the centroids
	td.mainWeight = 0
	for _, c := range td.mainCentroids {
		td.mainWeight += c.Weight
	}

	return td
}
708632
func (s *ADMMessage) SetData(v map[string]*string) *ADMMessage {
	s.Data = v
	return s
}
495053
func NewWithHTTP(http *http.Client) Client {
	c := newRouterClient()
	http.Transport = c.HTTP.Transport
	c.HTTP = http
	return c
}
374903
func (b Buffer) NData() []byte {
	buf := make([]byte, 4+b.Len())
	binary.BigEndian.PutUint32(buf, uint32(b.Len()))

	copy(buf[4:], b.Bytes())
	return buf
}
138701
func putData(v interface{}, pn *C.pn_data_t) {
	if v != nil {
		C.pn_data_clear(pn)
		marshal(v, pn)
	}
}
816264
func (sc *StripChart) AddData(name string, data []float64, style Style) {
	n := len(sc.ScatterChart.Data) + 1
	pd := make([]EPoint, len(data))
	nan := math.NaN()
	for i, d := range data {
		pd[i].X = d
		pd[i].Y = float64(n)
		pd[i].DeltaX, pd[i].DeltaY = nan, nan
	}
	if style.empty() {
		style = AutoStyle(len(sc.Data), false)
	}
	style.LineStyle = 0
	sc.ScatterChart.AddData(name, pd, PlotStylePoints, style)
}
1301828
func (c *BoxChart) AddData(name string, data []Box, style Style) {
	c.Data = append(c.Data, BoxChartData{name, style, data})
	ps := PlotStyle(PlotStylePoints | PlotStyleBox)
	c.Key.Entries = append(c.Key.Entries, KeyEntry{Text: name, Style: style, PlotStyle: ps})
	// TODO(vodo) min, max
}
1095301
func (s *PutRecordInput) SetData(v []byte) *PutRecordInput {
	s.Data = v
	return s
}
210899
func New(n Name, data []byte) Body {
	switch n {
	case
		AddrNPI,
		AddrTON,
		DataCoding,
		DestAddrNPI,
		DestAddrTON,
		ESMClass,
		ErrorCode,
		InterfaceVersion,
		MessageState,
		NumberDests,
		NoUnsuccess,
		PriorityFlag,
		ProtocolID,
		RegisteredDelivery,
		ReplaceIfPresentFlag,
		SMDefaultMsgID,
		SMLength,
		SourceAddrNPI,
		SourceAddrTON,
		UDHLength:
		if data == nil {
			data = []byte{0}
		}
		return &Fixed{Data: data[0]}
	case
		AddressRange,
		DestinationAddr,
		DestinationList,
		FinalDate,
		MessageID,
		Password,
		ScheduleDeliveryTime,
		ServiceType,
		SourceAddr,
		SystemID,
		SystemType,
		UnsuccessSme,
		ValidityPeriod:
		if data == nil {
			data = []byte{}
		}
		return &Variable{Data: data}
	case ShortMessage:
		if data == nil {
			data = []byte{}
		}
		return &SM{Data: data}
	case GSMUserData:
		udhData := []UDH{}
		if data != nil && len(data) > 2 {
			for i := 0; i < len(data); {
				udh := UDH{}
				udh.IEI = Fixed{Data: data[i]}
				udh.IELength = Fixed{Data: data[i+1]}
				udh.IEData = Variable{}
				l := int(data[i+1])
				for j := 2; j < l+2; j++ {
					udh.IEData.Data = append(udh.IEData.Data, data[i+j])
				}
				udhData = append(udhData, udh)
				i += l + 3 // Ignore one byte after IEData (which is 0x00)
			}
		}
		return &UDHList{Data: udhData}
	default:
		return nil
	}
}
588480
func NewErrUnexpectedData(msg string, data []byte) error {
	return &ErrUnexpectedData{Msg: msg, Data: data}
}
87435
func NewWithFile(path string) (*Database, error) {
	db := &Database{make(map[string]string), make(map[string]string), path}
	db.customPath = path

	blob, err := Asset("4byte.json")
	if err != nil {
		return nil, err
	}
	if err := json.Unmarshal(blob, &db.embedded); err != nil {
		return nil, err
	}
	// Custom file may not exist. Will be created during save, if needed.
	if _, err := os.Stat(path); err == nil {
		if blob, err = ioutil.ReadFile(path); err != nil {
			return nil, err
		}
		if err := json.Unmarshal(blob, &db.custom); err != nil {
			return nil, err
		}
	}
	return db, nil
}
142880
func (t *Table) AppendData(rec map[string]interface{}) *Table {
	t.Data = append(t.Data, rec)
	return t
}
21292
func WithData(ctx context.Context, data lager.Data) lager.Logger {
	return FromContext(ctx).WithData(data)
}
161962
func (c *ScatterChart) AddData(name string, data []EPoint, plotstyle PlotStyle, style Style) {

	// Update styles if non given
	if plotstyle.undefined() {
		plotstyle = PlotStylePoints
	}
	if style.empty() {
		style = AutoStyle(len(c.Data), false)
	}
	// Fix missing values in style
	if (plotstyle & PlotStyleLines) != 0 {
		if style.LineWidth <= 0 {
			style.LineWidth = 1
		}
		if style.LineColor == nil {
			style.LineColor = style.SymbolColor
		}
	}
	if (plotstyle&PlotStylePoints) != 0 && style.Symbol == 0 {
		style.Symbol = '#'
	}

	// Init axis
	if len(c.Data) == 0 {
		c.XRange.init()
		c.YRange.init()
	}

	// Add data
	scd := ScatterChartData{Name: name, PlotStyle: plotstyle, Style: style, Samples: data, Func: nil}
	c.Data = append(c.Data, scd)

	// Autoscale
	for _, d := range data {
		xl, yl, xh, yh := d.BoundingBox()
		c.XRange.autoscale(xl)
		c.XRange.autoscale(xh)
		c.YRange.autoscale(yl)
		c.YRange.autoscale(yh)
	}

	// Add key/legend entry
	if name != "" {
		ke := KeyEntry{Style: style, PlotStyle: plotstyle, Text: name}
		c.Key.Entries = append(c.Key.Entries, ke)
	}
}
777534
func (coff *Coff) AddData(symbol string, data Sizer) {
	coff.addSymbol(symbol)
	coff.Data = append(coff.Data, data)
	coff.SectionHeader32.SizeOfRawData += uint32(data.Size())
}