// FindFirst implements the Tree interface.
963419
func (t *tree) FindAll(f func(v interface{}) (bool, error)) []Changer {
	ns, err := t.container.root.findAll(func(fn *node) (bool, error) {
		return f(fn.content.value())
	})
	if err != nil {
		return []Changer{&changer{nil, err}}
	}
	var cs []Changer
	for _, n := range ns {
		cs = append(cs, &changer{n, nil})
	}
	return cs
}
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
}
684034
func (t *Tree) First() (k generic.T, v generic.U) {
	if q := t.first; q != nil {
		q := &q.d[0]
		k, v = q.k, q.v
	}
	return
}
207523
func (iter *Iterator) First() bool {
	// Seek the start key if the iterator was created with one.  This will
	// result in either an exact match, the first greater key, or an
	// exhausted iterator if no such key exists.
	iter.isNew = false
	if iter.startKey != nil {
		return iter.seek(iter.startKey, true, true)
	}

	// The smallest key is in the left-most node.
	iter.parents = parentStack{}
	for node := iter.root; node != nil; node = node.left {
		if node.left == nil {
			iter.node = node
			return true
		}
		iter.parents.Push(node)
	}
	return false
}
313988
func (tc *TreeCache) findNode(path string) (*TreeNode, error) {
	if !strings.HasPrefix(path, tc.root.path) {
		return nil, ErrRootNotMatch
	}

	path = strings.TrimPrefix(path, tc.root.path)
	current := tc.root
	for _, part := range strings.Split(path, "/") {
		if part == "" {
			continue
		}
		next, exists := current.FindChild(part)
		if !exists {
			return nil, ErrNodeNotFound
		}
		current = next
	}

	return current, nil
}
938000
func (l *lex) matchFirst(args ...string) bool {
	for _, m := range args {
		if l.match(m) {
			return true
		}
	}
	return false
}
23895
func (p *Prog) findChildLeaf() string {
	for {
		if len(p.Child) == 0 {
			return p.Path
		}
		p = p.Child[p.keys()[0]]
	}
}
728039
func GetFirstPod(client *client.Client, namespace string, selector map[string]string) (*api.Pod, error) {
	var pods *api.PodList
	for pods == nil || len(pods.Items) == 0 {
		var err error
		labelSelector := labels.SelectorFromSet(selector)
		options := unversioned.ListOptions{LabelSelector: unversioned.LabelSelector{labelSelector}}
		if pods, err = client.Pods(namespace).List(options); err != nil {
			return nil, err
		}
		if len(pods.Items) == 0 {
			time.Sleep(2 * time.Second)
		}
	}
	pod := &pods.Items[0]
	return pod, nil
}
447197
func (q *LinkedBlockingDeque) PeekFirst() interface{} {
	var result interface{}
	q.lock.Lock()
	if q.first == nil {
		result = nil
	} else {
		result = q.first.item
	}
	q.lock.Unlock()
	return result
}
1251093
func (t *tree) First() (k uint64, v *roaring.Container) {
	if q := t.first; q != nil {
		q := &q.d[0]
		k, v = q.k, q.v
	}
	return k, v
}
245433
func (c *Cursor) First() (key []byte, value []byte) {
	_assert(c.bucket.tx.db != nil, "tx closed")
	c.stack = c.stack[:0]
	p, n := c.bucket.pageNode(c.bucket.root)
	c.stack = append(c.stack, elemRef{page: p, node: n, index: 0})
	c.first()

	// If we land on an empty page then move to the next value.
	// https://github.com/boltdb/bolt/issues/450
	if c.stack[len(c.stack)-1].count() == 0 {
		c.next()
	}

	k, v, flags := c.keyValue()
	if (flags & uint32(bucketLeafFlag)) != 0 {
		return k, nil
	}
	return k, v

}
858685
func (l PrimaryLayer) SeekFirst() (e *PrimaryEnumerator, err error) {
	l.lock.Lock()
	e, err = l.store.SeekFirst()
	l.lock.Unlock()
	return
}
631716
func getFirstChildEl(n *html.Node) *html.Node {
	c := n.FirstChild
	for c != nil && c.Type != html.ElementNode {
		c = c.NextSibling
	}
	return c
}
1278404
func (ref Reference) LimitToFirst(limit int) Query {
	ref.limitToFirst = limit
	return &ref
}
908752
func arrayFirst(input interface{}) interface{} {
	if input == nil {
		return nil
	}

	arr := reflect.ValueOf(input)

	if arr.Len() == 0 {
		return nil
	}

	return arr.Index(0).Interface()
}
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
}
234653
func lowerFirst(s string) string {
	if s == "" {
		return ""
	}

	str := ""
	strlen := len(s)

	/**
	  Loop each char
	  If is uppercase:
	    If is first char, LOWER it
	    If the following char is lower, LEAVE it
	    If the following char is upper OR numeric, LOWER it
	    If is the end of string, LEAVE it
	  Else lowercase
	*/

	foundLower := false
	for i := range s {
		ch := s[i]
		if isUpper(ch) {
			switch {
			case i == 0:
				str += string(ch + 32)
			case !foundLower: // Currently just a stream of capitals, eg JSONRESTS[erver]
				if strlen > (i+1) && isLower(s[i+1]) {
					// Next char is lower, keep this a capital
					str += string(ch)
				} else {
					// Either at end of string or next char is capital
					str += string(ch + 32)
				}
			default:
				str += string(ch)
			}
		} else {
			foundLower = true
			str += string(ch)
		}
	}

	return str
}