// Combinations creates a new CombinationIterator for a given slice and
// desired output size.
329907
func Combinations(pool []interface{}, r int) (*CombinationIterator, error) {
	n := len(pool)

	if r > n {
		return nil, errors.New("Result size is larger than input")
	}

	iter := &CombinationIterator{
		pool: pool,
		n:    n,
		r:    r,
		res:  make([]interface{}, r, r),
		max:  lenCombinations(n, r),
	}

	iter.Reset()

	return iter, nil
}
807083
func Options(pkgs []*packages.Package) ([]interface{}, error) {
	var options []interface{}
	for _, p := range pkgs {
		for _, f := range p.Syntax {
			opts, err := FileOptions(f)
			if err != nil {
				return nil, err
			}
			options = append(options, opts...)
		}
	}
	return options, nil
}
271218
func CombineFields(s []Field) string {
	r := make([]string, len(s))
	for i, v := range s {
		r[i] = string(v)
	}
	return strings.Join(r, ",")
}
4777
func (s *stringSet) All() []string {
	all := []string{}
	for v := range s.values {
		all = append(all, v)
	}
	return all
}
927765
func (s Set) Merge(set Set) {
	for t, v := range set {
		if v {
			s[t] = true
		}
	}
}
1331810
func (p *qProp) combine(q qProp) {
	switch {
	case p.err != nil:
		// Do nothing
	case q.err != nil:
		p.err = q.err
	default:
		p.isAggregation = p.isAggregation || q.isAggregation
		p.isRowFunc = p.isRowFunc || q.isRowFunc
		if p.isAggregation && p.isRowFunc {
			p.err = errNestedAggregation
		}
	}
}
4517
func (d *Drain) CombineErrors() error {
	if d == nil || len(d.errors) == 0 {
		return nil
	}
	return drainError(d.errors)
}
33236
func (i *Index) Options() IndexOptions {
	i.mu.RLock()
	defer i.mu.RUnlock()
	return i.options()
}
1314201
func (c Comparators) Swap(i, j int) {
	c[j], c[i] = c[i], c[j]
}
999620
func Concaterator(iterators ...Iterator) Iterator {
	return func() Token {
		for len(iterators) > 0 {
			t := iterators[0]()
			if t != EOF {
				return t
			}
			iterators = iterators[1:]
		}
		return EOF
	}
}
869263
func (m *SortedMap) Keys() []string {
	keys := make([]string, 0, m.Size())
	m.trie.Allprefixed([]byte{}, func(k []byte, v interface{}) bool {
		keys = append(keys, string(k))
		return true
	})
	return keys
}
643793
func Mix(rate int8, inputs []Input) Input {
	CheckRate(rate)
	switch len(inputs) {
	case 0:
		panic("can not mix empty inputs slice")
	case 1:
		return inputs[0]
	case 2:
		return inputs[0].Add(inputs[1])
	case 3:
		return Sum3(rate, inputs[0], inputs[1], inputs[2])
	case 4:
		return Sum4(rate, inputs[0], inputs[1], inputs[2], inputs[3])
	default:
		head := []Input{Sum4(rate, inputs[0], inputs[1], inputs[2], inputs[3])}
		return Mix(rate, append(head, inputs[4:]...))
	}
}
717451
func (o Options) sortedKeys() []int {
	// Send all values for a given key
	var codes []int
	for k := range o {
		codes = append(codes, int(k))
	}

	sort.Sort(sort.IntSlice(codes))
	return codes
}
390736
func (s *set) All() []interface{} {
	all := []interface{}{}
	for v := range s.values {
		all = append(all, v)
	}
	return all
}
1061738
func (iter *CombinationIterator) Reset() {
	iter.iters = 0

	iter.indices = make([]int, iter.r)
	for i := 0; i < iter.r; i++ {
		iter.indices[i] = i
	}

	iter.res = make([]interface{}, iter.r, iter.r)
}
498012
func (tp *treePermutations) permute() []*Tree {
	tp.computeDescendantPermutations()

	it := newBFSIterator(tp.originalRoot)
	for {
		v := it.Next()
		if v == nil {
			break
		}

		if len(v.Descendants) == 0 {
			continue
		}

		// Iterate over all permutations where v exists
		// and separate them to 2 sets: a indiceSet where it exists and a indiceSet where it doesn't
		var permutationsWhereVexists []*TreeVertex
		var permutationsWhereVdoesntExist []*TreeVertex
		for _, perm := range tp.permutations {
			if perm.Exists(v.Id) {
				permutationsWhereVexists = append(permutationsWhereVexists, perm)
			} else {
				permutationsWhereVdoesntExist = append(permutationsWhereVdoesntExist, perm)
			}
		}

		// Remove the permutations where v exists from the permutations
		tp.permutations = permutationsWhereVdoesntExist

		// Next, we replace each occurrence of a permutation where v exists,
		// with multiple occurrences of its descendants permutations
		for _, perm := range permutationsWhereVexists {
			// For each permutation of v's descendants, clone the graph
			// and create a new graph with v replaced with the permutated graph
			// of v connected to the descendant permutation
			for _, permutation := range tp.descendantPermutations[v] {
				subGraph := &TreeVertex{
					Id:          v.Id,
					Data:        v.Data,
					Descendants: permutation,
				}
				newTree := perm.Clone()
				newTree.replace(v.Id, subGraph)
				// Add the new option to the permutations
				tp.permutations = append(tp.permutations, newTree)
			}
		}
	}

	res := make([]*Tree, len(tp.permutations))
	for i, perm := range tp.permutations {
		res[i] = perm.ToTree()
	}
	return res
}
104734
func (pt PrimitiveTypes) Swap(i, j int) {
	pt[i], pt[j] = pt[j], pt[i]
}