// Data returns all the elements as a slice.
542575
func (t *PairTree) Data() []Pair {
	arr := make([]Pair, t.Len())
	var i int
	i = 0
	t.Do(func(v Pair) bool {
		arr[i] = v
		i++
		return true
	})
	return arr
}
402844
func (t *TopK) Elements() []*Element {
	if t.elements.Len() == 0 {
		return make([]*Element, 0)
	}

	elements := make(elementHeap, t.elements.Len())
	copy(elements, *t.elements)
	heap.Init(&elements)
	topK := make([]*Element, 0, t.k)

	for elements.Len() > 0 {
		topK = append(topK, heap.Pop(&elements).(*Element))
	}

	return topK
}
40862
func Strings(data []string) []string {
	sort.Strings(data)
	n := Uniq(sort.StringSlice(data))
	return data[:n]
}
201432
func (b *Builder) Slice() (Slice, error) {
	if b.buf.IsEmpty() {
		return Slice{}, nil
	}
	bytes, err := b.Bytes()
	return bytes, WithStack(err)
}
199019
func (s Set) Elements() (els []string) {
	els = make([]string, 0, len(s))
	for el := range s {
		els = append(els, el)
	}

	return els
}
1299118
func (l *List) All() ([]string, error) {
	rows, err := l.host.db.Query("SELECT " + listCol + " FROM " + l.table + " ORDER BY id")
	if err != nil {
		return []string{}, err
	}
	defer rows.Close()
	var (
		values []string
		value  string
	)
	for rows.Next() {
		err = rows.Scan(&value)
		if !l.host.rawUTF8 {
			Decode(&value)
		}
		values = append(values, value)
		if err != nil {
			// Unusual, worthy of panic
			panic(err.Error())
		}
	}
	if err := rows.Err(); err != nil {
		// Unusual, worthy of panic
		panic(err.Error())
	}
	return values, nil
}
61169
func sliceCompress(data []byte) []byte {
	var buf bytes.Buffer
	cmp, _ := zlib.NewWriterLevel(&buf, zlib.BestSpeed)
	cmp.Write(data)
	cmp.Close()
	return buf.Bytes()
}
925309
func (v *Value) Slice(i, j int) *Value {
	switch v.getResolvedValue().Kind() {
	case reflect.Array, reflect.Slice:
		return AsValue(v.getResolvedValue().Slice(i, j).Interface())
	case reflect.String:
		runes := []rune(v.getResolvedValue().String())
		return AsValue(string(runes[i:j]))
	default:
		logf("Value.Slice() not available for type: %s\n", v.getResolvedValue().Kind().String())
		return AsValue([]int{})
	}
}
428983
func (p *Plot) data() (dataPoints, []string, error) {
	var (
		series []*timeSeries
		count  int
	)

	for _, as := range p.series {
		for _, s := range as.series {
			if s != nil {
				series = append(series, s)
				count += s.len
			}
		}
	}

	var (
		size   = 1 + len(series)
		nan    = math.NaN()
		labels = make([]string, size)
		data   = make(dataPoints, 0, count)
	)

	labels[0] = "Seconds"

	sort.Slice(series, func(i, j int) bool {
		return series[i].attack+series[i].label <
			series[j].attack+series[j].label
	})

	for i, s := range series {
		points, err := lttb.Downsample(s.len, p.threshold, s.iter())
		if err != nil {
			return nil, nil, err
		}

		for _, p := range points {
			pt := make([]float64, size)
			for j := range pt {
				pt[j] = nan
			}
			pt[0], pt[i+1] = p.X, p.Y
			data = append(data, pt)
		}

		labels[i+1] = s.attack + ": " + s.label
	}

	sort.Sort(data)

	return data, labels, nil
}
739267
func (p *parser) parse() (*Microdata, error) {
	toplevelNodes := []*html.Node{}

	walkNodes(p.tree, func(n *html.Node) {
		if _, ok := getAttr("itemscope", n); ok {
			if _, ok := getAttr("itemprop", n); !ok {
				toplevelNodes = append(toplevelNodes, n)
			}
		}
		if id, ok := getAttr("id", n); ok {
			p.identifiedNodes[id] = n
		}
	})

	for _, node := range toplevelNodes {
		item := NewItem()
		p.data.addItem(item)
		p.readAttr(item, node)
		p.readItem(item, node, true)
	}

	return p.data, nil
}
666486
func Slice(list, start, end cty.Value) (cty.Value, error) {
	return SliceFunc.Call([]cty.Value{list, start, end})
}
509965
func (de *decoder) slice(slval reflect.Value, vb []byte) error {
	// Find the element type, and create a temporary instance of it.
	eltype := slval.Type().Elem()
	val := reflect.New(eltype).Elem()

	// Decide on the wiretype to use for decoding.
	var wiretype int
	switch eltype.Kind() {
	case reflect.Bool, reflect.Int32, reflect.Int64, reflect.Int,
		reflect.Uint32, reflect.Uint64, reflect.Uint:
		if (eltype.Kind() == reflect.Int || eltype.Kind() == reflect.Uint) && eltype.Size() < 8 {
			return errors.New("detected a 32bit machine, please either use (u)int64 or (u)int32")
		}
		switch eltype {

		case sfixed32type:
			wiretype = 5 // Packed 32-bit representation
		case sfixed64type:
			wiretype = 1 // Packed 64-bit representation
		case ufixed32type:
			wiretype = 5 // Packed 32-bit representation
		case ufixed64type:
			wiretype = 1 // Packed 64-bit representation
		default:
			wiretype = 0 // Packed varint representation
		}

	case reflect.Float32:
		wiretype = 5 // Packed 32-bit representation

	case reflect.Float64:
		wiretype = 1 // Packed 64-bit representation

	case reflect.Uint8: // Unpacked byte-slice
		if slval.Kind() == reflect.Array {
			if slval.Len() != len(vb) {
				return errors.New("array length and buffer length differ")
			}
			for i := 0; i < slval.Len(); i++ {
				// no SetByte method in reflect so has to pass down by uint64
				slval.Index(i).SetUint(uint64(vb[i]))
			}
		} else {
			slval.SetBytes(vb)
		}
		return nil

	default: // Other unpacked repeated types
		// Just unpack and append one value from vb.
		if err := de.putvalue(2, val, 0, vb); err != nil {
			return err
		}
		if slval.Kind() != reflect.Slice {
			return errors.New("append to non-slice")
		}
		slval.Set(reflect.Append(slval, val))
		return nil
	}

	// Decode packed values from the buffer and append them to the slice.
	for len(vb) > 0 {
		rem, err := de.value(wiretype, vb, val)
		if err != nil {
			return err
		}
		slval.Set(reflect.Append(slval, val))
		vb = rem
	}
	return nil
}
267770
func (d PixSlice) Slice(newSliceType reflect.Type) interface{} {
	sv := reflect.ValueOf(d)
	newSlice := reflect.New(newSliceType)
	hdr := (*reflect.SliceHeader)(unsafe.Pointer(newSlice.Pointer()))
	hdr.Cap = sv.Cap() * int(sv.Type().Elem().Size()) / int(newSliceType.Elem().Size())
	hdr.Len = sv.Len() * int(sv.Type().Elem().Size()) / int(newSliceType.Elem().Size())
	hdr.Data = uintptr(sv.Pointer())
	return newSlice.Elem().Interface()
}
1038276
func (r *Reply) Slice(s interface{}) error {
	if r.Type() == ReplyNil {
		return ErrNil
	}
	if r.Type() != ReplyArray {
		return ErrType
	}
	if len(r.arrayValue) == 0 {
		return nil
	}
	switch s := s.(type) {
	case *[]int:
		*s = make([]int, len(r.arrayValue))
		for i := range r.arrayValue {
			x, err := r.arrayValue[i].Int()
			if err != nil && err != ErrNil {
				return err
			}
			(*s)[i] = int(x)
		}
		return nil
	case *[]int64:
		*s = make([]int64, len(r.arrayValue))
		for i := range r.arrayValue {
			x, err := r.arrayValue[i].Int()
			if err != nil && err != ErrNil {
				return err
			}
			(*s)[i] = x
		}
		return nil
	case *[]float64:
		*s = make([]float64, len(r.arrayValue))
		for i := range r.arrayValue {
			x, err := r.arrayValue[i].Float()
			if err != nil && err != ErrNil {
				return err
			}
			(*s)[i] = x
		}
		return nil
	case *[]bool:
		*s = make([]bool, len(r.arrayValue))
		for i := range r.arrayValue {
			x, err := r.arrayValue[i].Bool()
			if err != nil && err != ErrNil {
				return err
			}
			(*s)[i] = x
		}
		return nil
	case *[]string:
		*s = make([]string, len(r.arrayValue))
		for i := range r.arrayValue {
			x, err := r.arrayValue[i].String()
			if err != nil && err != ErrNil {
				return err
			}
			(*s)[i] = x
		}
		return nil
	case *[][]byte:
		*s = make([][]byte, len(r.arrayValue))
		for i := range r.arrayValue {
			x, err := r.arrayValue[i].Bytes()
			if err != nil && err != ErrNil {
				return err
			}
			(*s)[i] = x
		}
		return nil
	case *[]FixInt:
		*s = make([]FixInt, len(r.arrayValue))
		for i := range r.arrayValue {
			x, err := r.arrayValue[i].FixInt()
			if err != nil && err != ErrNil {
				return err
			}
			(*s)[i] = FixInt(x)
		}
		return nil
	case *[]VarInt:
		*s = make([]VarInt, len(r.arrayValue))
		for i := range r.arrayValue {
			x, err := r.arrayValue[i].VarInt()
			if err != nil && err != ErrNil {
				return err
			}
			(*s)[i] = VarInt(x)
		}
		return nil
	case *[]*Pair:
		if len(r.arrayValue)%2 != 0 {
			return ErrType
		}
		*s = make([]*Pair, len(r.arrayValue)/2)
		for i := 0; i < len(r.arrayValue)/2; i++ {
			first, err := r.arrayValue[2*i].Bytes()
			if err != nil && err != ErrNil {
				return err
			}
			second, err := r.arrayValue[2*i+1].Bytes()
			if err != nil && err != ErrNil {
				return err
			}
			(*s)[i] = &Pair{first, second}
		}
		return nil
	default:
		return ErrConvert
	}
	return nil
}
233935
func (exp *ArrayExpr) All() []Node {
	all := make([]Node, len(exp.Elements))
	for i, v := range exp.Elements {
		all[i] = v
	}
	return all
}
377382
func (m *Match) Data() []byte {
	tmpbuf := []byte{}
	// Use unsafe instead of C.GoBytes to avoid "cgo argument has Go
	// pointer to Go pointer" panic (see
	// https://github.com/hillu/go-yara/issues/5)
	hdr := (*reflect.SliceHeader)(unsafe.Pointer(&tmpbuf))
	hdr.Data = uintptr(*(*unsafe.Pointer)(unsafe.Pointer(&(m.cptr.anon0))))
	hdr.Len = int(m.cptr.length)
	hdr.Cap = int(m.cptr.length)
	buf := make([]byte, len(tmpbuf))
	copy(buf, tmpbuf)
	return buf
}
39089
func Slice(slice interface{}, less func(i, j int) bool) {
	Sort(SliceSorter(slice, less))
}