<commit_before>package lease

// Set is a set of leases.
type Set []Lease

// Match returns the subset of leases which match the given parameters.
func (s Set) Match(resource, consumer string) (matches Set) {
	for p := range s {
		if s[p].Match(resource, consumer) {
			matches = append(matches, s[p])
		}
	}
	return
}

// Index returns the index of the first lease within s that matches the given
// parameters, or -1 if no such lease is present in s.
func (s Set) Index(resource, consumer string) (index int) {
	for p := range s {
		if s[p].Match(resource, consumer) {
			return p
		}
	}
	return -1
}<commit_msg>lease: Added Environment() to lease.Set<commit_after>package lease

// Set is a set of leases.
type Set []Lease

// Match returns the subset of leases which match the given parameters.
func (s Set) Match(resource, consumer string) (matches Set) {
	for p := range s {
		if s[p].Match(resource, consumer) {
			matches = append(matches, s[p])
		}
	}
	return
}

// Index returns the index of the first lease within s that matches the given
// parameters, or -1 if no such lease is present in s.
func (s Set) Index(resource, consumer string) (index int) {
	for p := range s {
		if s[p].Match(resource, consumer) {
			return p
		}
	}
	return -1
}

// Environment returns a slice of environment values from the leases. Keys are
// are supplied in preferential order, and the first key in each lease that
// exists is returned as the value for that key.
func (s Set) Environment(keys ...string) (values []string) {
	for _, l := range s {
		for _, key := range keys {
			if value, ok := l.Environment[key]; ok {
				values = append(values, value)
				break
			}
		}
	}
	return
}
{'fraction_non_alphanumeric': 0.10873440285204991, 'fraction_numerical': 0.0023767082590612004, 'mean_word_length': 3.2311557788944723, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3248895', 'n_tokens_mistral': 555, 'n_tokens_neox': 517, 'n_words': 233}