// enumerate returns a list of values and creates a copy if specified
494538
func (kv *boltKV) enumerate(prefix string) (kvdb.KVPairs, error) {
	if kv.db == nil {
		return nil, kvdb.ErrNotFound
	}

	// XXX FIXME some bug above this cases the prefix to be pre-loaded.
	prefix = strings.TrimPrefix(prefix, kv.domain)
	prefix = kv.domain + prefix

	var kvps = make(kvdb.KVPairs, 0, 100)

	kv.db.View(func(tx *bolt.Tx) error {
		bucket := tx.Bucket(pxBucket)
		if bucket == nil {
			logrus.Warnf("Requested bucket not found in internal KVDB: %v",
				pxBucket,
			)
			return kvdb.ErrNotFound
		}

		c := bucket.Cursor()
		for k, v := c.First(); k != nil; k, v = c.Next() {
			if strings.HasPrefix(string(k), prefix) && !strings.Contains(string(k), "/_") {
				var kvp *kvdb.KVPair
				if err := json.Unmarshal(v, &kvp); err != nil {
					logrus.Warnf("Enumerated prefix could not be parsed from KVDB: %v, %v (%v)",
						prefix,
						v,
						err,
					)
					logrus.Fatalf("Could not enumerate internal KVDB: %v: %v",
						v,
						err,
					)
					return err
				}
				kv.normalize(kvp)
				kvps = append(kvps, kvp)
			}
		}
		return nil
	})

	return kvps, nil
}
132535
func (s Int) List() []int {
	res := make(sortableSliceOfInt, 0, len(s))
	for key := range s {
		res = append(res, key)
	}
	sort.Sort(res)
	return []int(res)
}
1260931
func (nc *NumberConstraint) Enum(l ...interface{}) *NumberConstraint {
	if nc.enums == nil {
		nc.enums = Enum()
	}
	nc.enums.Enum(l...)
	return nc
}
656562
func (m *enumerator) Next() error {
	m.lowCurr += 1
	if m.lowCurr >= len(m.lowIdxs) {
		// move all the current low iterators forwards
		for _, vi := range m.lowIdxs {
			err := m.itrs[vi].Next()
			if err != nil && err != vellum.ErrIteratorDone {
				return err
			}
			m.currKs[vi], m.currVs[vi] = m.itrs[vi].Current()
		}
		// can skip any empty keys encountered at this point
		m.updateMatches(true)
	}
	if m.lowK == nil && len(m.lowIdxs) == 0 {
		return vellum.ErrIteratorDone
	}
	return nil
}
231215
func (self Object) Keys() []string {
	var keys []string
	self.object.enumerate(false, func(name string) bool {
		keys = append(keys, name)
		return true
	})
	return keys
}
21355
func (m *MockCluster) Enumerate() (api.Cluster, error) {
	ret := m.ctrl.Call(m, "Enumerate")
	ret0, _ := ret[0].(api.Cluster)
	ret1, _ := ret[1].(error)
	return ret0, ret1
}
890179
func (s *Struct) generateEnums(dir string) error {
	for _, f := range s.Fields {
		if f.Enum == nil {
			continue
		}
		if err := f.Enum.generate(dir); err != nil {
			return err
		}
	}
	return nil
}
1323703
func EnumSlice(val, sep string, enumValMap map[string]int32) ([]int32, error) {
	s := strings.Split(val, sep)
	values := make([]int32, len(s))
	for i, v := range s {
		value, err := Enum(v, enumValMap)
		if err != nil {
			return values, err
		}
		values[i] = value
	}
	return values, nil
}
254710
func (c *Corpus) EnumerateBlobMeta(fn func(camtypes.BlobMeta) bool) {
	for _, bm := range c.blobs {
		if !fn(*bm) {
			return
		}
	}
}
956401
func NewEnumElementDef(init ...*EnumElementDef) *EnumElementDef {
	var o *EnumElementDef
	if len(init) == 1 {
		o = init[0]
	} else {
		o = new(EnumElementDef)
	}
	return o
}
811691
func (kv *memKV) enumerate(prefix string) (kvdb.KVPairs, error) {
	var kvp = make(kvdb.KVPairs, 0, 100)
	prefix = kv.domain + prefix

	for k, v := range kv.m {
		if strings.HasPrefix(k, prefix) && !strings.Contains(k, "/_") {
			kvpLocal := v.copy()
			kvpLocal.Key = k
			kv.normalize(kvpLocal)
			kvp = append(kvp, kvpLocal)
		}
	}

	return kvp, nil
}
210533
func (finder PackageFinder) Enumerate(cancel <-chan struct{}) collection.Enumerator {
	results := make(chan interface{})
	go func() {
		defer close(results)

		filepath.Walk(finder.Root(), func(localPath string, info os.FileInfo, openErr error) (err error) {
			if !info.IsDir() || openErr != nil {
				return
			}
			if info.Name() == "vendor" {
				err = filepath.SkipDir
				return
			}

			files := &token.FileSet{}

			if pkgs, parseErr := parser.ParseDir(files, localPath, nil, 0); parseErr != nil || len(pkgs) < 1 {
				return
			}

			select {
			case results <- localPath:
				// Intentionally Left Blank
			case <-cancel:
				err = errors.New("enumeration cancelled")
				return
			}

			return
		})
	}()
	return results
}
1090138
func (c *Corpus) EnumeratePermanodesByNodeTypes(fn func(camtypes.BlobMeta) bool, camliNodeTypes []string) {
	for _, t := range camliNodeTypes {
		set := c.permanodesSetByNodeType[t]
		for br := range set {
			if bm := c.blobs[br]; bm != nil {
				if !fn(*bm) {
					return
				}
			}
		}
	}
}
241999
func EnumerateAllFrom(ctx context.Context, src BlobEnumerator, after string, fn func(blob.SizedRef) error) error {
	const batchSize = 1000
	var mu sync.Mutex // protects returning with an error while fn is still running
	errc := make(chan error, 1)
	for {
		ch := make(chan blob.SizedRef, 16)
		n := 0
		go func() {
			var err error
			for sb := range ch {
				if err != nil {
					continue
				}
				mu.Lock()
				err = fn(sb)
				mu.Unlock()
				after = sb.Ref.String()
				n++
			}
			errc <- err
		}()
		err := src.EnumerateBlobs(ctx, ch, after, batchSize)
		if err != nil {
			mu.Lock() // make sure fn callback finished; no need to unlock
			return err
		}
		if err := <-errc; err != nil {
			return err
		}
		if n == 0 {
			return nil
		}
	}
}
478101
func (kva *KvAlert) EnumerateWithinTimeRange(
	timeStart time.Time,
	timeEnd time.Time,
	resourceType api.ResourceType,
) ([]*api.Alert, error) {
	allAlerts := []*api.Alert{}
	resourceAlerts := []*api.Alert{}
	var err error

	kv := kva.GetKvdbInstance()
	if resourceType != 0 {
		resourceAlerts, err = kva.getResourceSpecificAlerts(resourceType, kv)
		if err != nil {
			return nil, err
		}
	} else {
		resourceAlerts, err = kva.getAllAlerts(kv)
		if err != nil {
			return nil, err
		}
	}
	for _, v := range resourceAlerts {
		alertTime := prototime.TimestampToTime(v.Timestamp)
		if alertTime.Before(timeEnd) && alertTime.After(timeStart) {
			allAlerts = append(allAlerts, v)
		}
	}
	return allAlerts, nil
}
632294
func (c *ClusterManager) Enumerate() (api.Cluster, error) {
	clusterState := api.Cluster{
		Id:     c.config.ClusterId,
		Status: c.status,
		NodeId: c.selfNode.Id,
	}

	if c.selfNode.Status == api.Status_STATUS_NOT_IN_QUORUM ||
		c.selfNode.Status == api.Status_STATUS_MAINTENANCE {
		// If the node is not yet ready, query the cluster db
		// for node members since gossip is not ready yet.
		clusterState.Nodes = c.enumerateFromClusterDB()
	} else {
		clusterState.Nodes = c.enumerateFromCache()
	}

	// Allow listeners to add/modify data
	for e := c.listeners.Front(); e != nil; e = e.Next() {
		if err := e.Value.(cluster.ClusterListener).Enumerate(clusterState); err != nil {
			logrus.Warnf("listener %s enumerate failed: %v",
				e.Value.(cluster.ClusterListener).String(), err)
			continue
		}
	}
	return clusterState, nil
}
734255
func (e Environment) List() []corev1.EnvVar {
	env := []corev1.EnvVar{}
	for k, v := range e {
		env = append(env, corev1.EnvVar{
			Name:  k,
			Value: v,
		})
	}
	sort.Sort(sortedEnvVar(env))
	return env
}