// FindFirst implements the KeyValueTree interface.
505066
func (t *keyValueTree) FindFirst(f func(k string, v interface{}) (bool, error)) KeyValueChanger {
	n, err := t.container.root.findFirst(func(fn *node) (bool, error) {
		return f(fn.content.key().(string), fn.content.value())
	})
	return &keyValueChanger{n, err}
}
373102
func FindFirstIdentity(node Node) string {
	l := findIdentities(node, nil).Strings()
	if len(l) == 0 {
		return ""
	}
	return l[0]
}
198015
func (t *Tree) Find(key interface{}) interface{} {
	if key != nil && t.root != nil {
		d := &findData{key, t.compare}
		node := d.finder(t.root)
		if node != nil {
			return node.value
		}
	}

	return nil
}
1211843
func (t *PrimaryTree) SeekFirst() (e *PrimaryEnumerator, err error) {
	q := t.first
	if q == nil {
		return nil, io.EOF
	}

	return btEPool1.get(nil, true, 0, q.d[0].k, q, t, atomic.LoadUint64(&t.ver)), nil
}
1367951
func (t *Trie) findNode(key string) (node *Node, index int) {
	curNode := t.root
	f := false
	for k, v := range key {
		if f {
			index = k
			f = false
		}
		if curNode.child[v] == nil {
			return nil, index
		}
		curNode = curNode.child[v]
		if curNode.exists {
			f = true
		}
	}

	if curNode.exists {
		index = len(key)
	}

	return curNode, index
}
900065
func (n *node) findDescendent(parent *node, key Key, canChange, hasChanged bool) (foundParent *node, found *node, changed bool) {
	//if there is no more key to look into, then return parent, n, and hasChanged.
	if key.IsEmpty() {
		return parent, n, hasChanged
	}
	//find the child at the next part in key, possibly creating or changing with canChange.
	child, changed := n.findChild(key[0], canChange)
	if child == nil {
		return parent, nil, changed
	}
	//recurse into children.
	return child.findDescendent(n, key[1:], canChange, changed || hasChanged)
}
361875
func (ls *LinearSeries) GetFirstValues() (x, y float64) {
	if ls.InnerSeries == nil || len(ls.XValues) == 0 {
		return
	}
	if ls.IsZero() {
		ls.computeCoefficients()
	}
	x, y = ls.GetValues(0)
	return
}
1312590
func (l *LogFile) searchFirstAvPath() error {
	for {
		if fsutil.Exists(l.Path()) {
			stats, err := os.Stat(l.Path())
			if err != nil {
				return err
			}
			if stats.Size() >= l.size {
				l.idx++
			} else {
				return nil
			}
		} else {
			return nil
		}
	}
}
431573
func (n *ModuleTreeNode) DepthFirst(f func(node *ModuleTreeNode) bool) {
	if !f(n) {
		for _, node := range n.Children {
			node.DepthFirst(f)
		}
	}
}
433968
func (t *SecondaryTree) SeekFirst() (e *SecondaryEnumerator, err error) {
	q := t.first
	if q == nil {
		return nil, io.EOF
	}

	return btEPool2.get(nil, true, 0, q.d[0].k, q, t, atomic.LoadUint64(&t.ver)), nil
}
1065289
func (s Selector) MatchFirst(n *html.Node) *html.Node {
	if s.Match(n) {
		return n
	}

	for c := n.FirstChild; c != nil; c = c.NextSibling {
		m := s.MatchFirst(c)
		if m != nil {
			return m
		}
	}
	return nil
}
504589
func (c *IterateChain) First() (Value, error) {
	c.start()
	defer c.end()
	if !c.next() {
		return nil, c.it.Err()
	}
	return c.it.Result(), nil
}
298360
func (k *KeyFinderImpl) FindForEncryption(ctx context.Context, tlfName string, tlfID chat1.TLFID,
	membersType chat1.ConversationMembersType, public bool) (res types.CryptKey, ni types.NameInfo, err error) {

	ckey := k.encCacheKey(tlfName, tlfID, membersType, public)
	existing, ok := k.lookupEncKey(ckey)
	if ok {
		return existing.key, existing.ni, nil
	}
	defer func() {
		if err == nil {
			k.writeEncKey(ckey, encItem{
				key: res,
				ni:  ni,
			})
		}
	}()

	return k.createNameInfoSource(ctx, membersType).EncryptionKey(ctx, tlfName, tlfID,
		membersType, public)
}
242277
func (trs *TaskResultSet) FirstValue() interface{} {
	for _, result := range trs.results {
		if result.Value != nil {
			return result.Value
		}
	}
	return nil
}
1037967
func (t *Tree) MatchFirst(topic string) interface{} {
	values := t.Match(topic)

	if len(values) > 0 {
		return values[0]
	}

	return nil
}
27378
func FindPrimary(keyset *kops.Keyset) *kops.KeysetItem {
	var primary *kops.KeysetItem
	var primaryVersion *big.Int
	for i := range keyset.Spec.Keys {
		item := &keyset.Spec.Keys[i]
		version, ok := big.NewInt(0).SetString(item.Id, 10)
		if !ok {
			glog.Warningf("Ignoring key item with non-integer version: %q", item.Id)
			continue
		}

		if primaryVersion == nil || version.Cmp(primaryVersion) > 0 {
			primary = item
			primaryVersion = version
		}
	}
	return primary
}
293150
func (db *Database) First(dest DBModel, key interface{}) error {
	modelKey, _ := primaryKey(dest)
	in := reflect.Indirect(reflect.ValueOf(dest))
	in.FieldByName(modelKey).Set(reflect.Indirect(reflect.ValueOf(key)))
	return db.Model(dest).Where(in.Interface()).Scan(dest)
}