func (b *indexV1) Iterate(r IDRange, cb func(Info) error) error {
	startPos, err := b.findEntryPosition(r.StartID)
	if err != nil {
		return errors.Wrap(err, "could not find starting position")
	}

	stride := b.hdr.keySize + b.hdr.valueSize

	for i := startPos; i < b.hdr.entryCount; i++ {
		entry, err := safeSlice(b.data, int64(v1HeaderSize+stride*i), stride)
		if err != nil {
			return errors.Wrap(err, "unable to read from index")
		}

		key := entry[0:b.hdr.keySize]

		contentID := bytesToContentID(key)
		if contentID.comparePrefix(r.EndID) >= 0 {
			break
		}

		i, err := b.entryToInfo(contentID, entry[b.hdr.keySize:])
		if err != nil {
			return errors.Wrap(err, "invalid index data")
		}

		if err := cb(i); err != nil {
			return err
		}
	}

	return nil
}
// Iterate invokes the provided callback function for a range of contents in the index, sorted alphabetically.
// The iteration ends when the callback returns an error, which is propagated to the caller or when
// all contents have been visited.
Iterate invokes the provided callback function for a range of contents in the index, sorted alphabetically.
The iteration ends when the callback returns an error, which is propagated to the caller or when
all contents have been visited.
// Iterate invokes the provided callback function for a range of contents in the index sorted alphabetically . // The iteration ends when the callback returns an error which is propagated to the caller or when // all contents have been visited .
func (b *indexV1) Iterate(r IDRange, cb func(Info) error) error {
	startPos, err := b.findEntryPosition(r.StartID)
	if err != nil {
		return errors.Wrap(err, "could not find starting position")
	}
	stride := b.hdr.keySize + b.hdr.valueSize
	for i := startPos; i < b.hdr.entryCount; i++ {
		entry, err := safeSlice(b.data, int64(v1HeaderSize+stride*i), stride)
		if err != nil {
			return errors.Wrap(err, "unable to read from index")
		}
		key := entry[0:b.hdr.keySize]
		contentID := bytesToContentID(key)
		if contentID.comparePrefix(r.EndID) >= 0 {
			break
		}
		i, err := b.entryToInfo(contentID, entry[b.hdr.keySize:])
		if err != nil {
			return errors.Wrap(err, "invalid index data")
		}
		if err := cb(i); err != nil {
			return err
		}
	}
	return nil
}
func ( b * indexV1 ) Iterate ( r IDRange , cb func ( Info ) error ) error { startPos , err := b . findEntryPosition ( r . StartID ) if err != nil { return errors . Wrap ( err , " " ) } stride := b . hdr . keySize + b . hdr . valueSize for i := startPos ; i < b . hdr . entryCount ; i ++ { entry , err := safeSlice ( b . data , int64 ( v1HeaderSize + stride * i ) , stride ) if err != nil { return errors . Wrap ( err , " " ) } key := entry [ 0 : b . hdr . keySize ] contentID := bytesToContentID ( key ) if contentID . comparePrefix ( r . EndID ) >= 0 { break } i , err := b . entryToInfo ( contentID , entry [ b . hdr . keySize : ] ) if err != nil { return errors . Wrap ( err , " " ) } if err := cb ( i ) ; err != nil { return err } } return nil }
Iterate invokes the provided callback function for a range of contents in the index, sorted alphabetically.
Iterate invokes the provided callback function for a range of contents in the index sorted alphabetically .