// IndexOfInt gets the index at which the first occurrence of an int value is found in array or return -1
// if the value cannot be found
967304
func IndexOfInt(a []int, x int) int {
	return indexOf(len(a), func(i int) bool { return a[i] == x })
}
1264814
func (s *regexFcd) pushInt(I int) {
	if s.intDepth >= len(s.intStack) {
		expanded := make([]int, s.intDepth*2)
		copy(expanded, s.intStack)
		s.intStack = expanded
	}

	s.intStack[s.intDepth] = I
	s.intDepth++
}
340773
func Index(limit, offset, length int) (start, end int) {
	if offset > length {
		return length, length
	} else if limit+offset > length {
		return offset, length
	}

	return offset, offset + limit
}
5068
func (tr Row) ForceInt(nn int) (val int) {
	val, _ = tr.IntErr(nn)
	return
}
888458
func (d *Context) GetInt(index int) int {
	return int(C.duk_get_int(d.duk_context, C.duk_idx_t(index)))
}
1329973
func (l *list) FindIndex(pred func(interface{}) bool) int {
	curr := l
	idx := 0
	for {
		if pred(curr.head) {
			return idx
		}
		tail, _ := curr.Tail()
		if tail.IsEmpty() {
			return -1
		}
		curr = tail.(*list)
		idx += 1
	}
}
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()
}
790902
func IndexN(s, sep string, n int) int {
	sepIdx := 0
	for i := 0; i < n; i++ {
		nextIdx := strings.Index(s[sepIdx:], sep)
		if nextIdx == -1 {
			return -1 // ### return, not found ###
		}
		sepIdx += nextIdx + 1
	}
	return sepIdx - 1
}
805106
func (c *Context) Int(name string) int {
	return lookupInt(name, c.flagSet)
}
1141721
func (d *Context) ToInt(index int) int {
	return int(C.duk_to_int(d.duk_context, C.duk_idx_t(index)))
}
568140
func (h *Hostlist) IndexOf(host *Hostname) int {
	for index, found := range *h {
		if found.Equal(host) {
			return index
		}
	}
	return -1
}
314622
func (list *List) IndexOf(s string) int {
	if list.length == 0 {
		return -1
	}
	tmp := list.first
	for i := 0; i < list.length; i++ {
		if tmp.Content == s {
			return i
		}
		if tmp.Next != nil {
			tmp = tmp.Next
		}
	}
	return -1
}
5999
func (s *Selection) IndexOfNode(node *html.Node) int {
	return indexInSlice(s.Nodes, node)
}
1636
func (g *Group) IndexFunc(f func(*Group)) *Statement {
	s := IndexFunc(f)
	g.items = append(g.items, s)
	return s
}
371170
func (l *State) TypeOf(index int) Type {
	return l.valueToType(l.indexToValue(index))
}
652837
func IndexOf(in interface{}, elem interface{}) int {
	inValue := reflect.ValueOf(in)

	elemValue := reflect.ValueOf(elem)

	inType := inValue.Type()

	if inType.Kind() == reflect.String {
		return strings.Index(inValue.String(), elemValue.String())
	}

	if inType.Kind() == reflect.Slice {
		for i := 0; i < inValue.Len(); i++ {
			if equal(inValue.Index(i).Interface(), elem) {
				return i
			}
		}
	}

	return -1
}
1103254
func toInt(v reflect.Value) int {
	i, _ := tryToInt(v)
	return i
}