// Next randomly returns an upstream target.
496927
func (b *randomBalancer) Next(c echo.Context) *ProxyTarget {
	if b.random == nil {
		b.random = rand.New(rand.NewSource(int64(time.Now().Nanosecond())))
	}
	b.mutex.RLock()
	defer b.mutex.RUnlock()
	return b.targets[b.random.Intn(len(b.targets))]
}
797232
func (a actions) next(r, c interface{}) (interface{}, error) {
	return a[0](r, c, a[1:])
}
124873
func (i *Uint16) Next() uint16 {
	i.lock.Lock()
	defer i.lock.Unlock()
	i.increment++
	return i.increment
}
1136541
func (batcher *UploadObjectsIterator) Next() bool {
	if batcher.inc {
		batcher.index++
	} else {
		batcher.inc = true
	}
	return batcher.index < len(batcher.Objects)
}
1033545
func (cu *cursor) Next() (*cb.Block, cb.Status) {
	// This only loops once, as signal reading indicates non-nil next
	for {
		next := cu.list.getNext()
		if next != nil {
			cu.list = next
			return cu.list.block, cb.Status_SUCCESS
		}
		<-cu.list.signal
	}
}
1212717
func (c *Ctx) Next() {
	c.index++
	c.handlers[c.index](c.parent)
}
1372313
func (iterator *LinkedBlockingDequeIterator) Next() interface{} {
	if iterator.next == nil {
		//TODO error or nil ?
		//panic(errors.New("NoSuchElement"))
		return nil
	}
	iterator.lastRet = iterator.next
	x := iterator.nextItem
	iterator.advance()
	return x
}
1018860
func (iter *iterator) Next() bool {
	if iter.first {
		iter.first = false
		return iter.n != nil
	}

	if iter.n == nil {
		return false
	}

	iter.n = iter.n.forward[0]
	return iter.n != nil
}
1112125
func (w *Watcher) Next(r Resource) (string, error) {
	return w.watcher.Next(r)
}
429583
func (m *logMultiplexer) Next() (chanIndex int, log *logpb.LogEntry, err error) {
	if m.heads == nil {
		// initialization
		m.heads = make([]logAndErr, len(m.Chans))
		for i := range m.heads {
			m.heads[i] = <-m.Chans[i].c
		}
	}

	// Choose the earliest one.
	// Note: using heap is overkill here.
	// Most of the time we deal with only two logs.
	earliest := -1
	earliestTime := time.Time{}
	for i, h := range m.heads {
		if h.err == io.EOF {
			continue
		}
		if h.err != nil {
			return 0, nil, h.err
		}

		curTime := m.Chans[i].start
		if h.TimeOffset != nil {
			offset, err := ptypes.Duration(h.TimeOffset)
			if err != nil {
				return 0, nil, err
			}
			curTime = curTime.Add(offset)
		}

		isEarlier := earliest == -1 ||
			curTime.Before(earliestTime) ||
			(curTime.Equal(earliestTime) && h.PrefixIndex < m.heads[earliest].PrefixIndex)
		if isEarlier {
			earliest = i
			earliestTime = curTime
		}
	}
	if earliest == -1 {
		// all finished
		return 0, nil, io.EOF
	}

	// Call f and replace the entry with the freshest one from the same
	// channel.
	earliestEntry := m.heads[earliest].LogEntry
	m.heads[earliest] = <-m.Chans[earliest].c
	return earliest, earliestEntry, nil
}
947901
func (i *memDbIter) Next() error {
	if i.reverse {
		i.iter.Prev()
	} else {
		i.iter.Next()
	}
	return nil
}
1042474
func (s *RedisQueueStore) Next(key string) (string, error) {
	if !strings.HasPrefix(key, s.prefix) {
		key = s.prefix + key
	}
	res, err := s.client.LPop(key).Result()
	if err == redis.Nil {
		return "", nil
	}
	return res, err
}
413247
func (r *tarReader) Next() error {
	header, err := r.reader.Next()
	r.header = header
	return err
}
190441
func (s *Schedule) Next(now, prev time.Time) time.Time {
	if s.triggered {
		return DistantFuture
	}

	// For an absolute schedule just look at the time table.
	if s.cronExpr != nil {
		return s.cronExpr.Next(now)
	}

	// Using relative schedule and this is a first invocation ever? Randomize
	// start time, so that a bunch of newly registered cron jobs do not start all
	// at once. Otherwise just wait for 'interval' seconds after previous
	// invocation.
	if prev.IsZero() {
		// Pass seed through math/rand to make small seeds (used by unit tests),
		// less special.
		rnd := rand.New(rand.NewSource(int64(s.randSeed))).Float64()
		return now.Add(time.Duration(float64(s.interval) * rnd))
	}
	next := prev.Add(s.interval)
	if next.Sub(now) < 0 {
		next = now
	}
	return next
}
1041296
func (wu *WaitUntil) Next(nextState MachineState) MachineState {
	wu.next = nextState
	return wu
}
696205
func (l Links) Next(href string, args ...interface{}) Links {
	return l.Link("next", href, args...)
}
308406
func (p *Pager) Next() *Pager {
	if !p.HasNext() {
		return nil
	}
	return p.pagers[p.PageNumber()]
}