// IterateBytes iterates through all bytes contained in the BitList
10000
func (bl *BitList) IterateBytes() <-chan byte {
	res := make(chan byte)

	go func() {
		c := bl.count
		shift := 24
		i := 0
		for c > 0 {
			res <- byte((bl.data[i] >> uint(shift)) & 0xFF)
			shift -= 8
			if shift < 0 {
				shift = 24
				i++
			}
			c -= 8
		}
		close(res)
	}()

	return res
}
1109925
func Int2Bytes(v int) []byte {
	ret := make([]byte, 4)
	Int2BytesTo(v, ret)
	return ret
}
610704
func Iterate(g func() Streamer) Streamer {
	var (
		s     Streamer
		first = true
	)
	return StreamerFunc(func(samples [][2]float64) (n int, ok bool) {
		if first {
			s = g()
			first = false
		}
		if s == nil {
			return 0, false
		}
		for len(samples) > 0 {
			if s == nil {
				break
			}
			sn, sok := s.Stream(samples)
			if !sok {
				s = g()
			}
			samples = samples[sn:]
			n += sn
		}
		return n, true
	})
}
449100
func (kv *KV) Iterator(f func([]byte, []byte) bool) error {
	rows, err := kv.db.Query(
		fmt.Sprintf("SELECT k, v FROM %s", string(kv.table)),
	)
	if err != nil {
		return err
	}
	defer rows.Close()
	var k, v []byte
	for rows.Next() {
		if err = rows.Scan(&k, &v); err == nil {
			if !f(k, v) {
				break
			}
		}
	}
	return err
}
818087
func (iter *Iterator) SkipAndReturnBytes() []byte {
	iter.startCapture(iter.head)
	iter.Skip()
	return iter.stopCapture()
}
1263444
func WriteBytes(buf io.ByteWriter, data []byte) (n int, err error) {
	wb := func(b byte) (err error) {
		if err = buf.WriteByte(b); err == nil {
			n++
		}
		return
	}

	acc := byte(0)
	for i := 0; i < len(data); i++ {
		m := uint(i % 7)
		b := data[i]
		if err = wb(acc | 1 | ((b & (0xff << (m + 1))) >> m)); err != nil {
			return
		}
		acc = (b << (7 - m))
		if m == 6 {
			if err = wb(acc | 1); err != nil {
				return
			}
			acc = 0
		}
	}
	err = wb(acc)
	return
}
391559
func (this Collection) SubBytesAll(s interface{}) [][]byte {
    result := make([][]byte, len(this))

    for k, c := range this {
        result[k] = c.SubBytes(s)
    }

    return result
}
484213
func (bi *BigInt) SetBytes(buf []byte) {
	bi.bigint.SetBytes(common.CopyBytes(buf))
}
86663
func (vals *ValidatorSet) Iterate(fn func(index int, val *Validator) bool) {
	for i, val := range vals.Validators {
		stop := fn(i, val.Copy())
		if stop {
			break
		}
	}
}
161090
func (kv *KV) Iterator(f func([]byte, []byte) bool) error {
	return kv.db.View(func(txn *badger.Txn) error {
		opts := badger.DefaultIteratorOptions
		opts.PrefetchSize = 10
		it := txn.NewIterator(opts)
		defer it.Close()
		for it.Rewind(); it.Valid(); it.Next() {
			item := it.Item()
			if k := item.Key(); k != nil {
				v, err := item.Value()
				if err != nil {
					return err
				}
				if !f(k, v) {
					break
				}
			}
		}
		return nil
	})
}
1139962
func (t *Template) RenderBytes(context ...interface{}) ([]byte, error) {
	var b *bytes.Buffer
	err := t.Render(b, context...)
	return b.Bytes(), err
}
1295200
func (t TDigest) AsBytes() ([]byte, error) {
	buffer := new(bytes.Buffer)

	err := binary.Write(buffer, endianess, smallEncoding)

	if err != nil {
		return nil, err
	}

	err = binary.Write(buffer, endianess, t.compression)

	if err != nil {
		return nil, err
	}

	err = binary.Write(buffer, endianess, int32(t.summary.Len()))

	if err != nil {
		return nil, err
	}

	var x float64
	t.summary.ForEach(func(mean float64, count uint32) bool {
		delta := mean - x
		x = mean
		err = binary.Write(buffer, endianess, float32(delta))

		return err == nil
	})
	if err != nil {
		return nil, err
	}

	t.summary.ForEach(func(mean float64, count uint32) bool {
		err = encodeUint(buffer, count)
		return err == nil
	})
	if err != nil {
		return nil, err
	}

	return buffer.Bytes(), nil
}
1148838
func (bl *BitList) GetBytes() []byte {
	len := bl.count >> 3
	if (bl.count % 8) != 0 {
		len++
	}
	result := make([]byte, len)
	for i := 0; i < len; i++ {
		shift := (3 - (i % 4)) * 8
		result[i] = (byte)((bl.data[i/4] >> uint(shift)) & 0xFF)
	}
	return result
}
1056434
func (b *Buffer) ReadBytes(p []byte) {
	copy(p, b.Consume(len(p)))
}
460273
func (engine *Engine) Iterate(bean interface{}, fun IterFunc) error {
	session := engine.NewSession()
	defer session.Close()
	return session.Iterate(bean, fun)
}
543250
func (a *APIDefinition) IterateUserTypes(it UserTypeIterator) error {
	names := make([]string, len(a.Types))
	i := 0
	for n := range a.Types {
		names[i] = n
		i++
	}
	sort.Strings(names)
	for _, n := range names {
		if err := it(a.Types[n]); err != nil {
			return err
		}
	}
	return nil
}
297431
func (s *FileSet) Iterate(f func(*File) bool) {
	for i := 0; ; i++ {
		var file *File
		s.mutex.RLock()
		if i < len(s.files) {
			file = s.files[i]
		}
		s.mutex.RUnlock()
		if file == nil || !f(file) {
			break
		}
	}
}