// Seek positions the cursor at the passed seek key. If the key does not exist,
// the cursor is moved to the next key after seek. Returns the new pair.
//
// This function is part of the walletdb.ReadCursor interface implementation.
976897
func (c *cursor) Seek(seek []byte) (key, value []byte) {
	return (*bbolt.Cursor)(c).Seek(seek)
}
1233171
func (o *offsetReader) Seek(offset int64, whence int) (int64, error) {
	o.lock.Lock()
	defer o.lock.Unlock()

	return o.buf.Seek(offset, whence)
}
1038645
func (fod fileOrDir) Seek(offset int64, whence int) (n int64, err error) {
	defer func() {
		if err != nil {
			err = translateErr(err)
		}
	}()
	if fod.file == nil {
		return 0, libkbfs.NotFileError{}
	}
	return fod.file.Seek(offset, whence)
}
1365458
func (c *Cursor) seekCursor(bufferResponse bool) error {
	if c.lastErr != nil {
		return c.lastErr
	}

	if len(c.buffer) == 0 && len(c.responses) == 0 && c.closed {
		return errCursorClosed
	}

	// Loop over loading data, applying skips as necessary and loading more data as needed
	// until either the cursor is closed or finished, or we have applied all outstanding
	// skips and data is available
	for {
		c.applyPendingSkips(bufferResponse) // if we are buffering the responses, skip can drain from the buffer

		if bufferResponse && len(c.buffer) == 0 && len(c.responses) > 0 {
			if err := c.bufferNextResponse(); err != nil {
				return err
			}
			continue // go around the loop again to re-apply pending skips
		} else if len(c.buffer) == 0 && len(c.responses) == 0 && !c.finished {
			//  We skipped all of our data, load some more
			if err := c.fetchMore(); err != nil {
				return err
			}
			if c.closed {
				return nil
			}
			continue // go around the loop again to re-apply pending skips
		}
		return nil
	}
}
398756
func (f *File) Seek(offset int64, whence int) (int64, error) {
	if f.appendedF != nil {
		if f.appendedFileReader == nil {
			return 0, &os.PathError{
				Op:   "seek",
				Path: filepath.Base(f.appendedF.zipFile.Name),
				Err:  errors.New("file is closed"),
			}
		}
		return f.appendedFileReader.Seek(offset, whence)
	}
	if f.virtualF != nil {
		return f.virtualF.seek(offset, whence)
	}
	if f.virtualD != nil {
		return f.virtualD.seek(offset, whence)
	}
	return f.realF.Seek(offset, whence)
}
1203181
func (iter *dbCacheIterator) Seek(key []byte) bool {
	// Seek to the provided key in both the database and cache iterators
	// then choose the iterator that is both valid and has the larger key.
	iter.dbIter.Seek(key)
	iter.cacheIter.Seek(key)
	return iter.chooseIterator(true)
}
1226148
func (itr *roaringIterator) Seek(bseek, pseek uint64) {
	itr.itr.Seek((bseek * ShardWidth) + pseek)
}
386657
func (ri *readerOffsetsIterator) Seek(key []byte, b *faultBuffer) (exact, ok bool) {
	ri.first = false

	pre, i, j, pi := keyPrefix(key), 0, len(ri.r.offsets), 0

	for i < j {
		h := int(uint(i+j) >> 1)
		pi = ri.r.searchPrefix(h)
		ri.setIndex(h, pi)

		switch ri.Compare(key, pre, b) {
		case -1:
			i = h + 1
		case 1:
			j = h
		default:
			return true, true
		}
	}

	ri.setIndex(i, pi)
	if ri.i >= len(ri.r.offsets) {
		return false, false
	}

	for ri.pi < len(ri.r.prefixes) && ri.i >= ri.r.prefixes[ri.pi].total {
		ri.pi++
	}

	return bytes.Equal(ri.Key(b), key), true
}
1266078
func (b *PackBuffer) Seek(offset int64, whence int) (int64, error) {
	var abs int64
	switch whence {
	case 0:
		abs = offset
	case 1:
		abs = int64(b.r) + offset
	case 2:
		abs = int64(len(b.s)) + offset
	default:
		return 0, errors.New("bytes: invalid whence")
	}
	if abs < 0 {
		return 0, errors.New("bytes: negative position")
	}
	if abs >= 1<<31 {
		return 0, errors.New("bytes: position out of range")
	}
	b.r = int(abs)
	return abs, nil
}
751302
func (iter *Iterator) Seek(key []byte) bool {
	iter.isNew = false
	return iter.seek(key, true, true)
}
186309
func (r *Reader) Find(key []byte, o *db.ReadOptions) db.Iterator {
	return r.find(key, o, nil)
}
1189211
func (f *File) Seek(offset int64, whence int) (n int64, err error) {
	newOffset := offset
	switch whence {
	case io.SeekStart:
	case io.SeekCurrent:
		origOffset := atomic.LoadInt64(&f.offset)
		newOffset = origOffset + offset
	case io.SeekEnd:
		ei, err := f.fs.config.KBFSOps().Stat(f.fs.ctx, f.node)
		if err != nil {
			return 0, err
		}
		newOffset = int64(ei.Size) + offset
	}
	if newOffset < 0 {
		return 0, errors.Errorf("Cannot seek to offset %d", newOffset)
	}

	_ = atomic.SwapInt64(&f.offset, newOffset)
	return newOffset, nil
}
738111
func (mc *CCacheMetric) seekAsc(ts uint32) (uint32, bool) {
	log.Debugf("CCacheMetric seekAsc: seeking for %d in the keys %+d", ts, mc.keys)

	for i := 0; i < len(mc.keys) && mc.keys[i] <= ts; i++ {
		if mc.nextTs(mc.keys[i]) > ts {
			log.Debugf("CCacheMetric seekAsc: seek found ts %d is between %d and %d", ts, mc.keys[i], mc.nextTs(mc.keys[i]))
			return mc.keys[i], true
		}
	}

	log.Debug("CCacheMetric seekAsc: seekAsc unsuccessful")
	return 0, false
}
822726
func (l *DiagnosticLog) Seek(ctx context.Context, nlines int32) error {
	h, err := l.m.BrowseLog(ctx, l.Host, l.Key, math.MaxInt32, 0)
	if err != nil {
		return err
	}

	l.Start = h.LineEnd - nlines

	return nil
}
277887
func (client *AVTransport2) Seek(InstanceID uint32, Unit string, Target string) (err error) {
	// Request structure.
	request := &struct {
		InstanceID string
		Unit       string
		Target     string
	}{}
	// BEGIN Marshal arguments into request.

	if request.InstanceID, err = soap.MarshalUi4(InstanceID); err != nil {
		return
	}
	if request.Unit, err = soap.MarshalString(Unit); err != nil {
		return
	}
	if request.Target, err = soap.MarshalString(Target); err != nil {
		return
	}
	// END Marshal arguments into request.

	// Response structure.
	response := interface{}(nil)

	// Perform the SOAP call.
	if err = client.SOAPClient.PerformAction(URN_AVTransport_2, "Seek", request, response); err != nil {
		return
	}

	// BEGIN Unmarshal arguments from response.

	// END Unmarshal arguments from response.
	return
}
1155835
func (r *Reader) Seek(offset int64, whence int) (int64, error) {
	var abs int64
	switch whence {
	case 0:
		abs = offset
	case 1:
		abs = int64(r.i) + offset
	case 2:
		abs = int64(len(r.s)) + offset
	default:
		return 0, errors.New("bytes: invalid whence")
	}
	if abs < 0 {
		return 0, errors.New("bytes: negative position")
	}
	if abs >= 1<<31 {
		return 0, errors.New("bytes: position out of range")
	}
	r.i = int(abs)
	return abs, nil
}
142990
func (c *KeyCursor) Next() {
	if len(c.current) == 0 {
		return
	}
	// Do we still have unread values in the current block
	if !c.current[0].read() {
		return
	}
	c.current = c.current[:0]
	if c.ascending {
		c.nextAscending()
	} else {
		c.nextDescending()
	}
}