// Element returns a single element from a given list at the given index. If
// index is greater than the length of the list then it is wrapped modulo
// the list length.
484656
func Element(list, index cty.Value) (cty.Value, error) {
	return ElementFunc.Call([]cty.Value{list, index})
}
500010
func (s *IndicesAnalyzeService) Index(index string) *IndicesAnalyzeService {
	s.index = index
	return s
}
423253
func (s *Selection) Index() int {
	if len(s.Nodes) > 0 {
		return newSingleSelection(s.Nodes[0], s.document).PrevAll().Length()
	}
	return -1
}
901022
func (s *ValidateService) Index(index ...string) *ValidateService {
	s.index = append(s.index, index...)
	return s
}
366117
func (e *element) derive(toIndex index) (*element, error) {
	fromIndex := e.index

	positions, err := fromIndex.deriveBitTransformations(toIndex)
	if err != nil {
		return nil, err
	}

	buf := e.hash.CloneBytes()
	for _, position := range positions {
		// Flip the bit and then hash the current state.
		byteNumber := position / 8
		bitNumber := position % 8

		buf[byteNumber] ^= (1 << bitNumber)

		h := sha256.Sum256(buf)
		buf = h[:]
	}

	hash, err := chainhash.NewHash(buf)
	if err != nil {
		return nil, err
	}

	return &element{
		index: toIndex,
		hash:  *hash,
	}, nil
}
1073710
func (r *SearchRequest) Index(indices ...string) *SearchRequest {
	r.indices = append(r.indices, indices...)
	return r
}
1192125
func (e *Element) Next() *Element {
	if p := e.next; e.list != nil && p != &e.list.root {
		return p
	}
	return nil
}
549241
func (f *FieldSetType) Elements(elems ...FormElement) *FieldSetType {
	for _, e := range elems {
		t := reflect.TypeOf(e)
		switch {
		case t.Implements(reflect.TypeOf((*fields.FieldInterface)(nil)).Elem()):
			f.addField(e.(fields.FieldInterface))
		}
	}
	return f
}
1115154
func (l *List) remove(e *Element) *Element {
	if e.prev != nil {
		e.prev.next = e.next
	}
	if e.next != nil {
		e.next.prev = e.prev
	}
	e.next = nil // avoid memory leaks
	e.prev = nil // avoid memory leaks
	if e.list == l {
		l.len--
	}

	e.list = nil
	return e
}
266854
func (s *ClusterStateService) Index(index string) *ClusterStateService {
	s.indices = make([]string, 0)
	s.indices = append(s.indices, index)
	return s
}
857350
func (f *IndexFile) TagValueElem(name, key, value []byte) TagValueElem {
	tblk, ok := f.tblks[string(name)]
	if !ok {
		return nil
	}
	return tblk.TagValueElem(key, value)
}
1239084
func (a *AttributeValue) Element() *etree.Element {
	el := etree.NewElement("saml:AttributeValue")
	el.CreateAttr("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")
	el.CreateAttr("xmlns:xs", "http://www.w3.org/2001/XMLSchema")
	el.CreateAttr("xsi:type", a.Type)
	if a.NameID != nil {
		el.AddChild(a.NameID.Element())
	}
	el.SetText(a.Value)
	return el
}
397164
func (a *Attribute) Element() *etree.Element {
	el := etree.NewElement("saml:Attribute")
	if a.FriendlyName != "" {
		el.CreateAttr("FriendlyName", a.FriendlyName)
	}
	if a.Name != "" {
		el.CreateAttr("Name", a.Name)
	}
	if a.NameFormat != "" {
		el.CreateAttr("NameFormat", a.NameFormat)
	}
	for _, v := range a.Values {
		el.AddChild(v.Element())
	}
	return el
}
1121323
func (a *AttributeStatement) Element() *etree.Element {
	el := etree.NewElement("saml:AttributeStatement")
	for _, v := range a.Attributes {
		el.AddChild(v.Element())
	}
	return el
}
1277832
func (s *IndexService) Index(index string) *IndexService {
	s.index = index
	return s
}
1281849
func (s *IndicesOpenService) Index(index string) *IndicesOpenService {
	s.index = index
	return s
}
44454
func (v ElementBuildingVisitor) replaceListElement(meta apply.FieldMetaImpl, item *listItem) (*apply.ListElement, error) {
	meta.Name = item.Name
	result := &apply.ListElement{
		FieldMetaImpl:   meta,
		ListElementData: item.ListElementData,
		Values:          []apply.Element{},
	}

	// Use the max length to iterate over the slices
	for i := 0; i < max(len(item.GetRecordedList()), len(item.GetLocalList()), len(item.GetRemoteList())); i++ {

		// Lookup the item from each list
		data := apply.RawElementData{}
		if recorded, recordedSet := boundsSafeLookup(i, item.GetRecordedList()); recordedSet {
			data.SetRecorded(recorded)
		}
		if local, localSet := boundsSafeLookup(i, item.GetLocalList()); localSet {
			data.SetLocal(local)
		}
		if remote, remoteSet := boundsSafeLookup(i, item.GetRemoteList()); remoteSet {
			data.SetRemote(remote)
		}

		// Create the Item
		var s proto.Schema
		if item.Array != nil && item.Array.SubType != nil {
			s = item.Array.SubType
		}
		subitem, err := v.getItem(s, fmt.Sprintf("%d", i), data)
		if err != nil {
			return nil, err
		}

		// Build the element
		newelem, err := subitem.CreateElement(v)
		if err != nil {
			return nil, err
		}

		// Append the element to the list
		result.Values = append(result.Values, newelem)
	}

	return result, nil
}