// AbsIndex converts the acceptable index index to an absolute index (that
// is, one that does not depend on the stack top).
//
// http://www.lua.org/manual/5.2/manual.html#lua_absindex
325892
func (l *State) AbsIndex(index int) int {
	if index > 0 || isPseudoIndex(index) {
		return index
	}
	return l.top - l.callInfo.function + index
}
1086433
func appendIndex(is []int, i int) []int {
	// Make a new slice with capacity for a single additional element.
	x := make([]int, 0, len(is)+1)
	// Append the old slice to the new slice and then append the new
	// element.
	return append(append(x, is...), i)
}
1123421
func AscByFieldIndex(slice interface{}, index []int) {
	New(slice, FieldByIndexGetter(index), Ascending).Sort()
}
187336
func (b *CreateIndexService) Index(index string) *CreateIndexService {
	b.index = index
	return b
}
779313
func (table *Table) AddIndex(index *Index) {
	table.Indexes[index.Name] = index
}
1231730
func (v LocalValue) Absolute(m ModuleInstance) AbsLocalValue {
	return AbsLocalValue{
		Module:     m,
		LocalValue: v,
	}
}
132848
func (c C) Absdif(val Input) Input {
	return c.Add(val.Neg()).Abs()
}
856426
func (qt *quadtreeNode) getIndex(pRect AABB) int {
	horzMidpoint := qt.Bounds.Min.X + (aabbWidth(qt.Bounds) / 2)
	vertMidpoint := qt.Bounds.Min.Y + (aabbHeight(qt.Bounds) / 2)

	//pRect can completely fit within the top quadrants
	topQuadrant := (pRect.Min.Y < vertMidpoint) && (pRect.Max.Y < vertMidpoint)

	//pRect can completely fit within the bottom quadrants
	bottomQuadrant := (pRect.Min.Y > vertMidpoint)

	//pRect can completely fit within the left quadrants
	if (pRect.Min.X < horzMidpoint) && (pRect.Max.X < horzMidpoint) {
		if topQuadrant {
			return 1
		} else if bottomQuadrant {
			return 2
		}
	} else if pRect.Min.X > horzMidpoint {
		//pRect can completely fit within the right quadrants
		if topQuadrant {
			return 0
		} else if bottomQuadrant {
			return 3
		}
	}

	return -1 // index of the subnode (0-3), or -1 if pRect cannot completely fit within a subnode and is part of the parent node
}
287941
func (k KeyPress) Index() (ret int) {
	ret = int(k.Key)
	if k.Shift {
		ret += shift
	}
	if k.Alt {
		ret += alt
	}
	if k.Ctrl {
		ret += ctrl
	}
	if k.Super {
		ret += super
	}
	return
}
196281
func (api *API) Index(ctx context.Context, indexName string) (*Index, error) {
	span, _ := tracing.StartSpanFromContext(ctx, "API.Index")
	defer span.Finish()

	if err := api.validate(apiIndex); err != nil {
		return nil, errors.Wrap(err, "validating api method")
	}

	index := api.holder.Index(indexName)
	if index == nil {
		return nil, newNotFoundError(ErrIndexNotFound)
	}
	return index, nil
}
1176403
func (bA *BitArray) SetIndex(i int, v bool) bool {
	if bA == nil {
		return false
	}
	bA.mtx.Lock()
	defer bA.mtx.Unlock()
	return bA.setIndex(i, v)
}
543994
func (m *MapOfCharacterToGlyphIndex) Index(k rune) (int, bool) {
	/*for i, key := range m.Keys {
		if k == key {
			return i, true
		}
	}*/
	if index, ok := m.keyIndexs[k]; ok {
		return index, true
	}
	return -1, false
}
379801
func AscByIndex(slice interface{}, index int) {
	New(slice, IndexGetter(index), Ascending).Sort()
}
376248
func abs(slice []float64) []float64 {
	var newSlice []float64
	for _, value := range slice {
		if value < 0.0 {
			value = math.Abs(value)
		}
		newSlice = append(newSlice, value)
	}
	return newSlice
}
861987
func (s *IndicesSegmentsService) Index(indices ...string) *IndicesSegmentsService {
	s.index = append(s.index, indices...)
	return s
}
1115326
func (r Resource) Absolute(module ModuleInstance) AbsResource {
	return AbsResource{
		Module:   module,
		Resource: r,
	}
}
411011
func (s *SearchShardsService) Index(index ...string) *SearchShardsService {
	s.index = append(s.index, index...)
	return s
}