// AddSection adds a new child section to this Section with the provided name
552522
func (section *Section) AddSection(name string) *Section {
	childSection := newChildSection(section)
	section.values[name] = childSection
	return childSection
}
1306639
func (r *Resource) AddLinkCollection(rel Relation, l LinkCollection) {
	n := r.Links[rel]
	if n == nil {
		//new link
		r.Links[rel] = l
		return
	}

	if nc, ok := n.(LinkCollection); ok {
		r.Links[rel] = append(nc, l...)
		return
	}

	if nl, ok := n.(Link); ok {
		//prepend existing link to collection
		r.Links[rel] = append(LinkCollection{nl}, l...)
	}
}
1010086
func (c *Config) AddOption(section string, subsection string, key string, value string) *Config {
	if subsection == "" {
		c.Section(section).AddOption(key, value)
	} else {
		c.Section(section).Subsection(subsection).AddOption(key, value)
	}

	return c
}
1110531
func (n *Node) addLeaf(leaf *Leaf) error {
	extension := stripExtensionFromLastSegment(leaf.Wildcards)
	if extension != "" {
		if n.extensions == nil {
			n.extensions = make(map[string]*Leaf)
		}
		if n.extensions[extension] != nil {
			return errors.New("duplicate path")
		}
		n.extensions[extension] = leaf
		return nil
	}

	if n.leaf != nil {
		return errors.New("duplicate path")
	}
	n.leaf = leaf
	return nil
}
855928
func (n Namespace) AddStaticElements(values ...string) Namespace {
	for _, value := range values {
		n = append(n, NamespaceElement{Value: value})
	}
	return n
}
383887
func NewEntitiesSection(tags core.TagSlice) (*EntitiesSection, error) {
	section := new(EntitiesSection)

	if len(tags) == 3 {
		return section, nil
	}

	entities, err := NewEntityList(core.TagGroups(tags[2:len(tags)-1], 0))
	if err != nil {
		return nil, err
	}
	section.Entities = entities

	return section, nil
}
750008
func (n *XMLNode) AddChild(child *XMLNode) {
	child.parent = n
	if _, ok := n.Children[child.Name.Local]; !ok {
		n.Children[child.Name.Local] = []*XMLNode{}
	}
	n.Children[child.Name.Local] = append(n.Children[child.Name.Local], child)
}
1140040
func (f *File) NewSection(name string) (*Section, error) {
	if len(name) == 0 {
		return nil, errors.New("error creating new section: empty section name")
	} else if f.options.Insensitive && name != DefaultSection {
		name = strings.ToLower(name)
	}

	if f.BlockMode {
		f.lock.Lock()
		defer f.lock.Unlock()
	}

	if inSlice(name, f.sectionList) {
		return f.sections[name], nil
	}

	f.sectionList = append(f.sectionList, name)
	f.sections[name] = newSection(f, name)
	return f.sections[name], nil
}
618109
func NewHeaderSection(tags core.TagSlice) *HeaderSection {
	header := new(HeaderSection)
	header.Values = make(map[string]core.TagSlice)

	if len(tags) > 3 {
		groups := core.TagGroups(tags[2:len(tags)-1], 9)
		for _, group := range groups {
			var groupTags core.TagSlice
			headerKey := group[0].Value.ToString()

			if keyTags, ok := header.Values[headerKey]; ok {
				groupTags = keyTags
			} else {
				groupTags = make(core.TagSlice, 0)
			}

			groupTags = append(groupTags, group[1:]...)
			header.Values[headerKey] = groupTags
		}
	}

	// default values
	if _, ok := header.Values[tagACADVER]; !ok {
		header.Values[tagACADVER] = core.TagSlice{
			core.NewTag(1, core.NewStringValue("AC1009")),
		}
	}
	if _, ok := header.Values[tagDWGCODEPAGE]; !ok {
		header.Values[tagDWGCODEPAGE] = core.TagSlice{
			core.NewTag(3, core.NewStringValue("ANSI_1252")),
		}
	}

	return header
}
428155
func (section *Section) Set(name string, value Value) {
	section.values[name] = value
}
909084
func (p *parser) parseSection(inverse bool) (node, error) {
	t := p.read()
	if t.typ != tokenIdentifier {
		return nil, p.errorf(t, "unexpected token %s", t)
	}
	if next := p.read(); next.typ != tokenRightDelim {
		return nil, p.errorf(t, "unexpected token %s", t)
	}
	var (
		tokens []token
		stack  = 1
	)
	for {
		read, err := p.readv(t)
		if err != nil {
			return nil, err
		}
		tokens = append(tokens, read...)
		if len(read) > 1 {
			// Check the token that preceeded the matching identifier. For
			// section start and inverse tokens we increase the stack, otherwise
			// decrease.
			tt := read[len(read)-2]
			switch {
			case tt.typ == tokenSectionStart || tt.typ == tokenSectionInverse:
				stack++
			case tt.typ == tokenSectionEnd:
				stack--
			}
		}
		if stack == 0 {
			break
		}
	}
	nodes, err := subParser(tokens[:len(tokens)-3]).parse()
	if err != nil {
		return nil, err
	}
	section := &sectionNode{
		name:     t.val,
		inverted: inverse,
		elems:    nodes,
	}
	return section, nil
}
716170
func (m *Manifest) getSection(key string) *section {
	for _, s := range m.sections {
		if s.key == key {
			return s
		}
	}
	// create a new section for this manifest
	s := &section{key: key, entries: make([]string, 0)}
	m.sections = append(m.sections, s)

	return s
}
243238
func (f *File) getSection(name string) (*Section, int) {
	n := f.SectionManipFunc(name)

	// blank section isn't actually defined ...
	if f.sectionNameComp(n, "") {
		return f.sections[0], 0
	}

	// loop through lines and find section
	for idx, line := range f.lines {
		if s, ok := line.item.(*Section); ok && f.sectionNameComp(n, s.name) {
			return s, idx
		}
	}

	return nil, -1
}
823885
func (a *RtAttr) AddChild(attr NetlinkRequestData) {
	a.children = append(a.children, attr)
}
657550
func (c *Changelog) AddLineToSubsection(versionNum, subsectionName string, line *ChangeLine) {
	if line == nil {
		return
	}

	s := c.GetSubsectionOrCreate(versionNum, subsectionName)
	c.addToChangelines(&s.History, line)
}
460644
func (c *ChainIndexer) AddChildIndexer(indexer *ChainIndexer) {
	c.lock.Lock()
	defer c.lock.Unlock()

	c.children = append(c.children, indexer)

	// Cascade any pending updates to new children too
	sections := c.storedSections
	if c.knownSections < sections {
		// if a section is "stored" but not "known" then it is a checkpoint without
		// available chain data so we should not cascade it yet
		sections = c.knownSections
	}
	if sections > 0 {
		indexer.newHead(sections*c.sectionSize-1, false)
	}
}
319528
func (t *Tab) addNodes(node *gcdapi.DOMNode) {
	t.debugf("addNode id: %d\n", node.NodeId)
	t.debugf("%#v\n", node)
	newEle := t.nodeToElement(node)

	t.eleMutex.Lock()
	t.elements[newEle.id] = newEle
	t.eleMutex.Unlock()
	//log.Printf("Added new element: %s\n", newEle)
	t.requestChildNodes(newEle.id, 1)
	if node.Children != nil {
		// add child nodes
		for _, v := range node.Children {
			t.addNodes(v)
		}
	}
	if node.ContentDocument != nil {
		t.addNodes(node.ContentDocument)
	}
	t.lastNodeChangeTimeVal.Store(time.Now())
}