func (v *View) ReadToWriter(w io.Writer, count int64) (int64, error) {
	var (
		done int64
		n    int
		err  error
	)
	offset := 0 // Spill-over for batching.
	for buf := v.data.Front(); buf != nil && done < count; buf = buf.Next() {
		l := buf.write - buf.read - offset

		// Is this less than the minimum batch?
		if l < minBatch && (count-done) >= int64(minBatch) && (v.size-done) >= int64(minBatch) {
			tmp := make([]byte, minBatch)
			n, err = v.ReadAt(tmp, done)
			w.Write(tmp[:n])
			done += int64(n)
			offset = n - l // Reset below.
			if err != nil {
				break
			}
			continue
		}

		// Limit the write if necessary.
		if int64(l) >= (count - done) {
			l = int(count - done)
		}

		// Perform the actual write.
		n, err = w.Write(buf.data[buf.read+offset : buf.read+offset+l])
		done += int64(n)
		if err != nil {
			break
		}

		// Reset spill-over.
		offset = 0
	}
	return done, err
}
// ReadToWriter reads from the buffer into an io.Writer.
//
// N.B. This does not consume the bytes read. TrimFront should
// be called appropriately after this call in order to do so.
ReadToWriter reads from the buffer into an io.Writer.

N.B. This does not consume the bytes read. TrimFront should
be called appropriately after this call in order to do so.
// ReadToWriter reads from the buffer into an io . Writer . // // N . B . This does not consume the bytes read . TrimFront should // be called appropriately after this call in order to do so .
func (v *View) ReadToWriter(w io.Writer, count int64) (int64, error) {
	var (
		done int64
		n    int
		err  error
	)
	offset := 0 
	for buf := v.data.Front(); buf != nil && done < count; buf = buf.Next() {
		l := buf.write - buf.read - offset
		if l < minBatch && (count-done) >= int64(minBatch) && (v.size-done) >= int64(minBatch) {
			tmp := make([]byte, minBatch)
			n, err = v.ReadAt(tmp, done)
			w.Write(tmp[:n])
			done += int64(n)
			offset = n - l 
			if err != nil {
				break
			}
			continue
		}
		if int64(l) >= (count - done) {
			l = int(count - done)
		}
		n, err = w.Write(buf.data[buf.read+offset : buf.read+offset+l])
		done += int64(n)
		if err != nil {
			break
		}
		offset = 0
	}
	return done, err
}
func ( v * View ) ReadToWriter ( w io . Writer , count int64 ) ( int64 , error ) { var ( done int64 n int err error ) offset := 0 for buf := v . data . Front ( ) ; buf != nil && done < count ; buf = buf . Next ( ) { l := buf . write - buf . read - offset if l < minBatch && ( count - done ) >= int64 ( minBatch ) && ( v . size - done ) >= int64 ( minBatch ) { tmp := make ( [ ] byte , minBatch ) n , err = v . ReadAt ( tmp , done ) w . Write ( tmp [ : n ] ) done += int64 ( n ) offset = n - l if err != nil { break } continue } if int64 ( l ) >= ( count - done ) { l = int ( count - done ) } n , err = w . Write ( buf . data [ buf . read + offset : buf . read + offset + l ] ) done += int64 ( n ) if err != nil { break } offset = 0 } return done , err }
ReadToWriter reads from the buffer into an io.Writer.
ReadToWriter reads from the buffer into an io . Writer .
// Spill-over for batching. // Is this less than the minimum batch? // Reset below. // Limit the write if necessary. // Perform the actual write. // Reset spill-over.