// sortEntriesByPath sorts the entries in the table by path and returns the
// table; this is useful for tests
334996
func (t *MountTable) sortEntriesByPathDepth() *MountTable {
	sort.Slice(t.Entries, func(i, j int) bool {
		return len(strings.Split(t.Entries[i].Namespace().Path+t.Entries[i].Path, "/")) < len(strings.Split(t.Entries[j].Namespace().Path+t.Entries[j].Path, "/"))
	})
	return t
}
1307619
func (s *State) ModuleByPath(path addrs.ModuleInstance) *ModuleState {
	if s == nil {
		return nil
	}
	s.Lock()
	defer s.Unlock()

	return s.moduleByPath(path)
}
1098802
func (idx *MemoryIndex) EntriesByOffset() (EntryIter, error) {
	count, err := idx.Count()
	if err != nil {
		return nil, err
	}

	iter := &idxfileEntryOffsetIter{
		entries: make(entriesByOffset, count),
	}

	entries, err := idx.Entries()
	if err != nil {
		return nil, err
	}

	for pos := 0; int64(pos) < count; pos++ {
		entry, err := entries.Next()
		if err != nil {
			return nil, err
		}

		iter.entries[pos] = entry
	}

	sort.Sort(iter.entries)

	return iter, nil
}
764602
func FindEntityByName(path string, structName string) (*Table, error) {
	// find all entites in the given path
	entities, _, err := findEntities([]string{path}, []string{})
	if err != nil {
		return nil, err
	}

	// filter entites with the given struct name
	entitiesFilteredByName := []*Table{}
	for _, table := range entities {
		if table.StructName == structName {
			entitiesFilteredByName = append(entitiesFilteredByName, table)
		}
	}

	// only one entity with given name should be found
	if len(entitiesFilteredByName) == 0 {
		return nil, errors.Errorf("no entity named %s found in the path %s", structName, path)
	}
	if len(entitiesFilteredByName) > 1 {
		return nil, errors.Errorf("more than one entities named %s found in the path %s", structName, path)
	}

	return entitiesFilteredByName[0], nil
}
374332
func (tc *TabletStatsCache) getOrCreateEntry(target *querypb.Target) *tabletStatsCacheEntry {
	// Fast path (most common path too): Read-lock, return the entry.
	if e := tc.getEntry(target.Keyspace, target.Shard, target.TabletType); e != nil {
		return e
	}

	// Slow path: Lock, will probably have to add the entry at some level.
	tc.mu.Lock()
	defer tc.mu.Unlock()

	s, ok := tc.entries[target.Keyspace]
	if !ok {
		s = make(map[string]map[topodatapb.TabletType]*tabletStatsCacheEntry)
		tc.entries[target.Keyspace] = s
	}
	t, ok := s[target.Shard]
	if !ok {
		t = make(map[topodatapb.TabletType]*tabletStatsCacheEntry)
		s[target.Shard] = t
	}
	e, ok := t[target.TabletType]
	if !ok {
		e = &tabletStatsCacheEntry{
			all:        make(map[string]*TabletStats),
			aggregates: make(map[string]*querypb.AggregateStats),
		}
		t[target.TabletType] = e
	}
	return e
}
109359
func SortByChartName(list []*rspb.Release) {
	s := &sorter{list: list}
	s.less = func(i, j int) bool {
		chi := s.list[i].Chart
		chj := s.list[j].Chart

		ni := ""
		if chi != nil && chi.Metadata != nil {
			ni = chi.Metadata.Name
		}

		nj := ""
		if chj != nil && chj.Metadata != nil {
			nj = chj.Metadata.Name
		}

		return ni < nj
	}
	sort.Sort(s)
}
320733
func (api *ArchiveAPI) SortByName(reverse bool) *ArchiveAPI {
	api.sortByName(reverse)
	return api
}
76433
func (api *RegionAPI) SortByName(reverse bool) *RegionAPI {
	api.sortByName(reverse)
	return api
}
507122
func (t *topicTable) deleteEntry(e *topicEntry) {
	if printTestImgLogs {
		fmt.Printf("*- %d %v %016x %016x\n", mclock.Now()/1000000, e.topic, t.self.sha[:8], e.node.sha[:8])
	}
	ne := t.nodes[e.node].entries
	delete(ne, e.topic)
	if len(ne) == 0 {
		t.checkDeleteNode(e.node)
	}
	te := t.topics[e.topic]
	delete(te.entries, e.fifoIdx)
	if len(te.entries) == 0 {
		t.checkDeleteTopic(e.topic)
	}
	t.globalEntries--
}
150217
func (l sortEntries) Sort() {
	x := len(l)
	if x > 16 {
		sort.Sort(l)
	} else if len(l) > 1 {
		l.qSort()
	}
}
1136135
func (s *ScrollService) SortBy(sorter ...Sorter) *ScrollService {
	s.ss = s.ss.SortBy(sorter...)
	return s
}
579347
func (api *InterfaceAPI) SortByName(reverse bool) *InterfaceAPI {
	api.sortByName(reverse)
	return api
}
30204
func (o *ForwardingPathList) ForwardingPathListEntries(info *bambou.FetchingInfo) (ForwardingPathListEntriesList, *bambou.Error) {

	var list ForwardingPathListEntriesList
	err := bambou.CurrentSession().FetchChildren(o, ForwardingPathListEntryIdentity, &list, info)
	return list, err
}
981405
func (api *VPCRouterAPI) SortByName(reverse bool) *VPCRouterAPI {
	api.sortByName(reverse)
	return api
}
510352
func (fs *FileSorter) internalSort() (*comparableRow, error) {
	w := fs.workers[fs.cWorker]

	if !fs.fetched {
		sort.Sort(w)
		if w.err != nil {
			return nil, errors.Trace(w.err)
		}
		fs.fetched = true
	}
	if fs.cursor < len(w.buf) {
		r := w.buf[fs.cursor]
		fs.cursor++
		return r, nil
	}
	return nil, nil
}
167692
func (api *NoteAPI) SortByName(reverse bool) *NoteAPI {
	api.sortByName(reverse)
	return api
}
619217
func ResultsWithEntries(q Query, res []Entry) Results {
	i := 0
	return ResultsFromIterator(q, Iterator{
		Next: func() (Result, bool) {
			if i >= len(res) {
				return Result{}, false
			}
			next := res[i]
			i++
			return Result{Entry: next}, true
		},
	})
}