// Encode will encode the provided x and y coordinates into a Hilbert
// distance.
765067
func Encode(x, y int32) int64 {
	var rx, ry int32
	var d int64
	for s := int32(n / 2); s > 0; s /= 2 {
		rx = boolToInt(x&s > 0)
		ry = boolToInt(y&s > 0)
		d += int64(int64(s) * int64(s) * int64(((3 * rx) ^ ry)))
		rotate(s, rx, ry, &x, &y)
	}

	return d
}
1102564
func (jsonEncoder) Encode(v ...interface{}) string {
	var data interface{} = v
	if v == nil {
		// So that empty results produces `[]` and not `null`
		data = []interface{}{}
	} else if len(v) == 1 {
		data = v[0]
	}
	b, err := json.Marshal(data)
	if err != nil {
		panic(err)
	}
	log.Printf("%s", b)
	return string(b)
}
429794
func (enc *Encoder) Encode(v interface{}) error {
	if enc.err != nil {
		return enc.err
	}
	e := newEncodeState()
	err := e.marshal(v, encOpts{escapeHTML: enc.escapeHTML})
	if err != nil {
		return err
	}

	// Terminate each value with a newline.
	// This makes the output look a little nicer
	// when debugging, and some kind of space
	// is required if the encoded value was a number,
	// so that the reader knows there aren't more
	// digits coming.
	e.WriteByte('\n')

	b := e.Bytes()
	if enc.indentPrefix != "" || enc.indentValue != "" {
		if enc.indentBuf == nil {
			enc.indentBuf = new(bytes.Buffer)
		}
		enc.indentBuf.Reset()
		err = Indent(enc.indentBuf, b, enc.indentPrefix, enc.indentValue)
		if err != nil {
			return err
		}
		b = enc.indentBuf.Bytes()
	}
	if _, err = enc.w.Write(b); err != nil {
		enc.err = err
	}
	encodeStatePool.Put(e)
	return err
}
1248936
func Encode(value uint64) string {
	var res [16]byte
	var i int
	for i = len(res) - 1; value != 0; i-- {
		res[i] = base36[value%36]
		value /= 36
	}
	return string(res[i+1:])
}
479800
func Encode(g geom.T) (kml.Element, error) {
	switch g := g.(type) {
	case *geom.Point:
		return EncodePoint(g), nil
	case *geom.LineString:
		return EncodeLineString(g), nil
	case *geom.LinearRing:
		return EncodeLinearRing(g), nil
	case *geom.MultiLineString:
		return EncodeMultiLineString(g), nil
	case *geom.MultiPoint:
		return EncodeMultiPoint(g), nil
	case *geom.MultiPolygon:
		return EncodeMultiPolygon(g), nil
	case *geom.Polygon:
		return EncodePolygon(g), nil
	case *geom.GeometryCollection:
		return EncodeGeometryCollection(g)
	default:
		return nil, geom.ErrUnsupportedType{Value: g}
	}
}
711322
func (v BoolValue) encode(w io.Writer) error {
	return binary.Write(w, binary.BigEndian, v.valueType())
}
255253
func Encode(xs []float64, dim int) string {
	n := len(xs)
	ys := make([]int, n)
	for i := 0; i < n; i++ {
		ys[i] = int(1e5 * xs[i])
	}
	for i := n - 1; i >= dim; i-- {
		ys[i] -= ys[i-dim]
	}
	return EncodeInts(ys)
}
1180375
func encode(e encoder, metricRegistry metrics.Registry) ([]byte, error) {
	if e == nil {
		return nil, nil
	}

	var prepEnc prepEncoder
	var realEnc realEncoder

	err := e.encode(&prepEnc)
	if err != nil {
		return nil, err
	}

	if prepEnc.length < 0 || prepEnc.length > int(MaxRequestSize) {
		return nil, PacketEncodingError{fmt.Sprintf("invalid request size (%d)", prepEnc.length)}
	}

	realEnc.raw = make([]byte, prepEnc.length)
	realEnc.registry = metricRegistry
	err = e.encode(&realEnc)
	if err != nil {
		return nil, err
	}

	return realEnc.raw, nil
}
1221160
func Encode(dst, src []byte) ([]byte, error) {
	if n := MaxEncodedLen(len(src)); len(dst) < n {
		dst = make([]byte, n)
	}

	var srcPtr unsafe.Pointer
	if len(src) != 0 {
		srcPtr = unsafe.Pointer(&src[0])
	}

	dLen := C.size_t(len(dst))
	status := C.snappy_compress((*C.char)(srcPtr), C.size_t(len(src)),
		(*C.char)(unsafe.Pointer(&dst[0])), &dLen)
	if status != C.SNAPPY_OK {
		return nil, ErrCorrupt
	}

	return dst[:dLen], nil
}
238535
func (enc *Encoder) Encode(v interface{}) (int, error) {
	if v == nil {
		msg := "can't marshal nil interface"
		err := marshalError("Marshal", ErrNilInterface, msg, nil, nil)
		return 0, err
	}

	vv := reflect.ValueOf(v)
	vve := vv
	for vve.Kind() == reflect.Ptr {
		if vve.IsNil() {
			msg := fmt.Sprintf("can't marshal nil pointer '%v'",
				vv.Type().String())
			err := marshalError("Marshal", ErrBadArguments, msg,
				nil, nil)
			return 0, err
		}
		vve = vve.Elem()
	}

	return enc.encode(vve)
}
462878
func (c *CommitSig) Encode(w io.Writer, pver uint32) error {
	return WriteElements(w,
		c.ChanID,
		c.CommitSig,
		c.HtlcSigs,
	)
}
476301
func (m *Marshaller) Encode(obj interface{}, w io.Writer) error {
	m.writer.w = w
	err := m.marshal.Marshal(obj)
	m.writer.w = nil
	return err
}
516319
func (e *wktEncoder) encode(g *Geometry) (string, error) {
	cstr := cGEOSWKTWriter_write(e.w, g.g)
	if cstr == nil {
		return "", Error()
	}
	return C.GoString(cstr), nil
}
448111
func (l *LineProtocol) Encode(mfs []*dto.MetricFamily) ([]byte, error) {
	return EncodeLineProtocol(mfs)
}
1318984
func (p Polyline) Encode(w io.Writer) error {
	e := &encoder{w: w}
	p.encode(e)
	return e.err
}
45463
func encode(data interface{}) ([]byte, error) {
	if data == nil {
		return nil, nil
	}
	buf := bytes.NewBuffer([]byte{})
	enc := gob.NewEncoder(buf)
	if err := enc.Encode(data); err != nil {
		return nil, err
	}
	return buf.Bytes(), nil
}
655641
func (b Ethernet) Encode(e *EthernetFields) {
	binary.BigEndian.PutUint16(b[ethType:], uint16(e.Type))
	copy(b[srcMAC:][:EthernetAddressSize], e.SrcAddr)
	copy(b[dstMAC:][:EthernetAddressSize], e.DstAddr)
}