// Sequences returns the model's sequence names and their next values.
545720
func (st *State) Sequences() (map[string]int, error) {
	sequences, closer := st.db().GetCollection(sequenceC)
	defer closer()

	var docs []sequenceDoc
	if err := sequences.Find(nil).All(&docs); err != nil {
		return nil, errors.Trace(err)
	}

	result := make(map[string]int)
	for _, doc := range docs {
		result[doc.Name] = doc.Counter
	}
	return result, nil
}
1159671
func (seq *Sequence) Next() (KSUID, error) {
	id := seq.Seed // copy
	count := seq.count
	if count > math.MaxUint16 {
		return Nil, errors.New("too many IDs were generated")
	}
	seq.count++
	return withSequenceNumber(id, uint16(count)), nil
}
295358
func PgTables(db models.XODB, schema string, relkind string) ([]*models.Table, error) {
	var err error

	// get the tables
	rows, err := models.PgTables(db, schema, relkind)
	if err != nil {
		return nil, err
	}

	// Get the tables that have a sequence defined.
	sequences, err := models.PgSequences(db, schema)
	if err != nil {
		// Set it to an empty set on error.
		sequences = []*models.Sequence{}
	}

	// Add information about manual FK.
	var tables []*models.Table
	for _, row := range rows {
		manualPk := true
		// Look for a match in the table name where it contains the sequence
		for _, sequence := range sequences {
			if sequence.TableName == row.TableName {
				manualPk = false
			}
		}
		tables = append(tables, &models.Table{
			TableName: row.TableName,
			Type:      row.Type,
			ManualPk:  manualPk,
		})
	}

	return tables, nil
}
830666
func (d *decodeState) next() []byte {
	startop, start := d.peekRecord()

	var endop int

	switch startop {
	case scanBeginArray:
		endop = scanEndArray
	case scanBeginObject:
		endop = scanEndObject
	case scanBeginLiteral:
		endop = scanEndLiteral
	default:
		panic(errPhase)
	}

	count := 1 //counts number of open and not closed brackets.
	d.skipRecord()
	end := 0 //end of value
	op := startop
	for count != 0 { //we need here cycle because of nested objects and slices
		op, end = d.takeRecord()

		if op == startop {
			count++
		}

		if op == endop {
			count--
		}

	}
	return d.data[start : end+1]
}
951386
func ExtractControlSequences(s string) ([]ControlSequence, error) {
	var list []ControlSequence
	for len(s) > 0 {
		start := strings.IndexByte(s, ltmark)
		if start == -1 {
			break
		}

		end := strings.IndexByte(s[start:], gtmark)
		if end == -1 {
			break
		}

		// Note that end is relative to start, so we need to
		// do `end + start` in order to move the string start
		// to the end of the control sequence
		rawseq := s[start : end+start+1]
		s = s[end+start:]

		seq, err := ParseControlSequence(rawseq)
		if err != nil {
			return nil, errors.Wrapf(err, `failed to parse '%s'`, rawseq)
		}
		list = append(list, seq)
	}

	return list, nil
}
133935
func (f *MathFuncs) Seq(n ...interface{}) ([]int64, error) {
	start := int64(1)
	end := int64(0)
	step := int64(1)
	if len(n) == 0 {
		return nil, fmt.Errorf("math.Seq must be given at least an 'end' value")
	}
	if len(n) == 1 {
		end = conv.ToInt64(n[0])
	}
	if len(n) == 2 {
		start = conv.ToInt64(n[0])
		end = conv.ToInt64(n[1])
	}
	if len(n) == 3 {
		start = conv.ToInt64(n[0])
		end = conv.ToInt64(n[1])
		step = conv.ToInt64(n[2])
	}
	return math.Seq(conv.ToInt64(start), conv.ToInt64(end), conv.ToInt64(step)), nil
}
823706
func (c *connections) Models() []string {
	models := set.NewStrings()
	for _, value := range c.values {
		models.Add(value.Model)
	}
	return models.Values()
}
730718
func (g *modelShim) Branches() ([]Generation, error) {
	branches, err := g.Model.Branches()
	if err != nil {
		return nil, errors.Trace(err)
	}

	res := make([]Generation, len(branches))
	for i, b := range branches {
		res[i] = b
	}
	return res, nil
}
1144587
func (r *showResults) Databases() []chronograf.Database {
	res := []chronograf.Database{}
	for _, u := range *r {
		for _, s := range u.Series {
			for _, v := range s.Values {
				if name, ok := v[0].(string); !ok {
					continue
				} else {
					d := chronograf.Database{Name: name}
					res = append(res, d)
				}
			}
		}
	}
	return res
}
521263
func (gms *genericMsgStore) FirstSequence() (uint64, error) {
	gms.RLock()
	first := gms.first
	gms.RUnlock()
	return first, nil
}
714575
func Sequence(meta SequenceMeta, r ...Renderable) *SequenceRenderer {
	if meta.Tag == "" {
		meta.Tag = "div"
	}

	s := SequenceRenderer{
		Publisher:    pub.Identity(),
		SequenceMeta: &meta,
	}

	s.Add(r...)

	return &s
}
1036620
func (s *AtomicSequence) Next() (uint64, error) {
	atomic.AddUint64(&s.current, atomic.LoadUint64(&s.increment))

	// Check for missed minimum condition
	if atomic.LoadUint64(&s.current) < atomic.LoadUint64(&s.minvalue) {
		return 0, errors.New("reached minimum bound of the sequence")
	}

	// Check for reached maximum condition
	if atomic.LoadUint64(&s.current) > atomic.LoadUint64(&s.maxvalue) {
		return 0, errors.New("reached maximum bound of sequence")
	}

	return atomic.LoadUint64(&s.current), nil
}
542905
func InterpretSequenceSet(imapSequenceSet string) (seqSet SequenceSet, err error) {
	// Ensure the sequence set is valid
	if !setRegexp.MatchString(imapSequenceSet) {
		return nil, errInvalidSequenceSetString(imapSequenceSet)
	}

	ranges := strings.Split(imapSequenceSet, ",")

	seqSet = make(SequenceSet, len(ranges))
	for index, rng := range ranges {
		seqSet[index], err = InterpretMessageRange(rng)
		if err != nil {
			return seqSet, err
		}
	}

	return seqSet, nil
}
930860
func (s *ClaimSeqnoProvider) SequenceForAccount(aid string) (xdr.SequenceNumber, error) {
	seqno, err := s.walletState.Remoter.AccountSeqno(s.mctx.Ctx(), stellar1.AccountID(aid))
	if err != nil {
		return 0, err
	}
	return xdr.SequenceNumber(seqno), nil
}
824068
func (m *metadataTracker) nextLocalSeq() int64 {
	m.mut.Lock()
	defer m.mut.Unlock()

	c := m.countsPtr(protocol.LocalDeviceID, 0)
	c.Sequence++
	return c.Sequence
}
1203639
func StartAtSequence(seq uint64) SubscriptionOption {
	return func(o *SubscriptionOptions) error {
		o.StartAt = pb.StartPosition_SequenceStart
		o.StartSequence = seq
		return nil
	}
}
1261220
func (itr *tagKeySliceIterator) Next() ([]byte, error) {
	if len(itr.keys) == 0 {
		return nil, nil
	}
	key := itr.keys[0]
	itr.keys = itr.keys[1:]
	return key, nil
}