// NextGeneration increments the max file ID and returns the new value.
15874
func (f *FileStore) NextGeneration() int {
	f.mu.Lock()
	defer f.mu.Unlock()
	f.currentGeneration++
	return f.currentGeneration
}
208121
func (sis *SegmentInfos) nextSegmentFilename() string {
	var nextGeneration int64
	if sis.generation == -1 {
		nextGeneration = 1
	} else {
		nextGeneration = sis.generation + 1
	}
	return util.FileNameFromGeneration(util.SEGMENTS, "", nextGeneration)
}
1316509
func (ds *DiskStorage) StorageGeneration() (initTime time.Time, random string, err error) {
	return ds.gen.StorageGeneration()
}
325232
func OneGenOf(gens ...gopter.Gen) gopter.Gen {
	if len(gens) == 0 {
		return Fail(reflect.TypeOf(nil))
	}
	return func(genParams *gopter.GenParameters) *gopter.GenResult {
		idx := genParams.Rng.Intn(len(gens))
		return gens[idx](genParams)
	}
}
41223
func NewFileChecksumGenerator(blocksize uint) *FileChecksumGenerator {
	return &FileChecksumGenerator{
		BlockSize:       blocksize,
		WeakRollingHash: rollsum.NewRollsum32Base(blocksize),
		//WeakRollingHash:  rollsum.NewRollsum16Base(blocksize),
		StrongHash:       DefaultStrongHashGenerator(),
		FileChecksumHash: DefaultFileHashGenerator(),
	}
}
714060
func (iter *FileIter) Next() (*File, error) {
	for {
		name, entry, err := iter.w.Next()
		if err != nil {
			return nil, err
		}

		if entry.Mode == filemode.Dir || entry.Mode == filemode.Submodule {
			continue
		}

		blob, err := GetBlob(iter.s, entry.Hash)
		if err != nil {
			return nil, err
		}

		return NewFile(name, entry.Mode, blob), nil
	}
}
1304883
func (s *GetPolicyVersionOutput) SetGenerationId(v string) *GetPolicyVersionOutput {
	s.GenerationId = &v
	return s
}
1046537
func NewGenerator(options ...Option) *Generator {
	g := &Generator{}

	for _, option := range options {
		option(g)
	}

	return g
}
348532
func (ri *runReverseIterator16) next() uint16 {
	if !ri.hasNext() {
		panic("no next available")
	}
	if ri.curIndex == -1 {
		panic("runReverseIterator.next() going beyond what is available")
	}
	if ri.curIndex == -2 {
		// first time is special
		ri.curIndex = int64(len(ri.rc.iv)) - 1
		ri.curPosInIndex = ri.rc.iv[ri.curIndex].length
	} else {
		if ri.curPosInIndex > 0 {
			ri.curPosInIndex--
		} else {
			ri.curIndex--
			ri.curPosInIndex = ri.rc.iv[ri.curIndex].length
		}
		ri.curSeq++
	}
	return ri.cur()
}
314829
func (c *IDCounter) NextID() packet.ID {
	c.mutex.Lock()
	defer c.mutex.Unlock()

	// ignore zeroes
	if c.next == 0 {
		c.next++
	}

	// cache next id
	id := c.next

	// increment id
	c.next++

	return id
}
787724
func (ri *runIterator16) next() uint16 {
	if !ri.hasNext() {
		panic("no Next available")
	}
	if ri.curIndex >= int64(len(ri.rc.iv)) {
		panic("runIterator.Next() going beyond what is available")
	}
	if ri.curIndex == -1 {
		// first time is special
		ri.curIndex = 0
	} else {
		ri.curPosInIndex++
		if int64(ri.rc.iv[ri.curIndex].start)+int64(ri.curPosInIndex) == int64(ri.rc.iv[ri.curIndex].last())+1 {
			ri.curPosInIndex = 0
			ri.curIndex++
		}
		ri.curSeq++
	}
	return ri.cur()
}
1361629
func (i *PostingsIterator) nextDocNumAtOrAfterClean(
	atOrAfter uint64) (uint64, bool, error) {
	n := i.Actual.Next()

	if !i.includeFreqNorm {
		for uint64(n) < atOrAfter && i.Actual.HasNext() {
			n = i.Actual.Next()
		}

		if uint64(n) < atOrAfter {
			return 0, false, nil // couldn't find anything
		}

		return uint64(n), true, nil
	}

	// freq-norm's needed, so maintain freq-norm chunk reader
	sameChunkNexts := 0 // # of times we called Next() in the same chunk

	nChunk := n / i.postings.sb.chunkFactor

	for uint64(n) < atOrAfter && i.Actual.HasNext() {
		n = i.Actual.Next()

		nChunkPrev := nChunk
		nChunk = n / i.postings.sb.chunkFactor

		if nChunk != nChunkPrev {
			sameChunkNexts = 0
		} else {
			sameChunkNexts += 1
		}
	}

	if uint64(n) < atOrAfter {
		// couldn't find anything
		return 0, false, nil
	}

	for j := 0; j < sameChunkNexts; j++ {
		err := i.currChunkNext(nChunk)
		if err != nil {
			return 0, false, fmt.Errorf("error optimized currChunkNext: %v", err)
		}
	}

	if i.currChunk != nChunk || i.currChunkFreqNorm == nil {
		err := i.loadChunk(int(nChunk))
		if err != nil {
			return 0, false, fmt.Errorf("error loading chunk: %v", err)
		}
	}

	return uint64(n), true, nil
}
1286932
func (n *Nexter) Next() (nextID uint64) {
	nextID = atomic.AddUint64(n.id, 1)
	return nextID - 1
}
616489
func (itr *SeriesIDSliceIterator) Next() (SeriesIDElem, error) {
	if len(itr.ids) == 0 {
		return SeriesIDElem{}, nil
	}
	id := itr.ids[0]
	itr.ids = itr.ids[1:]
	return SeriesIDElem{SeriesID: id}, nil
}
735812
func (i *ResourceInstance) GetGeneration(gen Generation) *ResourceInstanceObjectSrc {
	if gen == CurrentGen {
		return i.Current
	}
	if dk, ok := gen.(DeposedKey); ok {
		return i.Deposed[dk]
	}
	if gen == nil {
		panic(fmt.Sprintf("get with nil Generation"))
	}
	// Should never fall out here, since the above covers all possible
	// Generation values.
	panic(fmt.Sprintf("get invalid Generation %#v", gen))
}
680737
func (s *persistentSequencer) NextID() (uint64, error) {

	// nextID will be the unique sequence number returned if no errors are
	// encountered.
	var nextID uint64

	// If our sequence batch has not been exhausted, we can allocate the
	// next identifier in the range.
	s.mu.Lock()
	defer s.mu.Unlock()

	if s.nextID < s.horizonID {
		nextID = s.nextID
		s.nextID++

		return nextID, nil
	}

	// Otherwise, our sequence batch has been exhausted. We use the last
	// known sequence number on disk to mark the beginning of the next
	// sequence batch, and allocate defaultSequenceBatchSize (1000) at a
	// time.
	//
	// NOTE: This also will happen on the first invocation after startup,
	// i.e. when nextID and horizonID are both 0. The next sequence batch to be
	// allocated will start from the last known tip on disk, which is fine
	// as we only require uniqueness of the allocated numbers.
	var nextHorizonID uint64
	if err := s.db.Update(func(tx *bbolt.Tx) error {
		nextIDBkt := tx.Bucket(nextPaymentIDKey)
		if nextIDBkt == nil {
			return ErrSequencerCorrupted
		}

		nextID = nextIDBkt.Sequence()
		nextHorizonID = nextID + defaultSequenceBatchSize

		// Cannot fail when used in Update.
		nextIDBkt.SetSequence(nextHorizonID)

		return nil
	}); err != nil {
		return 0, err
	}

	// Never assign index zero, to avoid collisions with the EmptyKeystone.
	if nextID == 0 {
		nextID++
	}

	// If our batch sequence allocation succeed, update our in-memory values
	// so we can continue to allocate sequence numbers without hitting disk.
	// The nextID is incremented by one in memory so the in can be used
	// issued directly on the next invocation.
	s.nextID = nextID + 1
	s.horizonID = nextHorizonID

	return nextID, nil
}
20708
func (p *GenParameters) NextInt64() int64 {
	v := p.Rng.Int63()
	if p.NextBool() {
		return -v
	}
	return v
}