// Distinct removes duplicate elements from the sequence.
181716
func Distinct(arg interface{}, optArgs ...DistinctOpts) Term {
	opts := map[string]interface{}{}
	if len(optArgs) >= 1 {
		opts = optArgs[0].toMap()
	}
	return constructRootTerm("Distinct", p.Term_DISTINCT, []interface{}{arg}, opts)
}
704661
func (it *Unique) Close() error {
	it.seen = nil
	return it.subIt.Close()
}
619190
func SeqEquiv(s1 iseq.Seq, s2 iseq.Seq) bool {
	if s1 == s2 {
		return true
	}

	iter2 := s2

	for iter1 := s1; iter1 != nil; iter1 = iter1.Next() {
		if iter2 == nil || !Equiv(iter1.First(), iter2.First()) {
			return false
		}
		iter2 = iter2.Next()
	}

	return iter2 == nil
}
341478
func (stmt SelectStmt) All() SelectStmt {
	stmt.isDistinct = false
	stmt.distincts = nil
	return stmt
}
356742
func (m *MockTagIterator) Duplicate() TagIterator {
	ret := m.ctrl.Call(m, "Duplicate")
	ret0, _ := ret[0].(TagIterator)
	return ret0
}
133935
func (f *MathFuncs) Seq(n ...interface{}) ([]int64, error) {
	start := int64(1)
	end := int64(0)
	step := int64(1)
	if len(n) == 0 {
		return nil, fmt.Errorf("math.Seq must be given at least an 'end' value")
	}
	if len(n) == 1 {
		end = conv.ToInt64(n[0])
	}
	if len(n) == 2 {
		start = conv.ToInt64(n[0])
		end = conv.ToInt64(n[1])
	}
	if len(n) == 3 {
		start = conv.ToInt64(n[0])
		end = conv.ToInt64(n[1])
		step = conv.ToInt64(n[2])
	}
	return math.Seq(conv.ToInt64(start), conv.ToInt64(end), conv.ToInt64(step)), nil
}
300230
func (o *DistinctOption) Get() (bool, int) {
	if o == nil {
		return false, 0
	}
	return o.value == 1, o.value
}
1021770
func Deduplicate(in []string) []string {
	if len(in) == 0 {
		return in
	}
	out := make([]string, 0, len(in))
	seen := make(map[string]bool, len(in))
	for _, val := range in {
		if _, ok := seen[val]; !ok {
			out = append(out, val)
			seen[val] = true
		}
	}
	return out
}
107905
func (s Seq) Merge(t Seq) (union Seq, ok bool) {
	if union = s; s == t {
		ok = true
		return
	}
	if s.Start != 0 && t.Start != 0 {
		// s and t are any combination of "n", "n:m", or "n:*"
		if s.Start > t.Start {
			s, t = t, s
		}
		// s starts at or before t, check where it ends
		if (s.Stop >= t.Stop && t.Stop != 0) || s.Stop == 0 {
			return s, true // s is a superset of t
		}
		// s is "n" or "n:m", if m == ^uint32(0) then t is "n:*"
		if s.Stop+1 >= t.Start || s.Stop == ^uint32(0) {
			return Seq{s.Start, t.Stop}, true // s intersects or touches t
		}
		return
	}
	// exactly one of s and t is "*"
	if s.Start == 0 {
		if t.Stop == 0 {
			return t, true // s is "*", t is "n:*"
		}
	} else if s.Stop == 0 {
		return s, true // s is "n:*", t is "*"
	}
	return
}
1051390
func uniqueEntries(paths []string) []string {
	m := make(set.StringSet)
	for _, p := range paths {
		if !m.Contains(p) {
			m.Add(p)
		}
	}
	return m.ToSlice()
}
1007382
func (list *List) Uniq() *List {
	if list.length < 2 {
		return list
	}
	m := make(map[string]bool)
	prev := list.first
	m[prev.Content] = true
	tmp := prev.Next
	for i := 0; i < list.length-1; i++ {
		if m[tmp.Content] {
			prev.Next = tmp.Next
			tmp = tmp.Next
		} else {
			m[tmp.Content] = true
			prev = tmp
			tmp = prev.Next
		}
		if tmp == nil {
			break
		}
	}
	return list
}
431761
func DistinctIntersectUint64Arr(arr [][]uint64) []uint64 {
	// create a map to count all the instances of the strings
	arrLength := len(arr)
	tempMap := make(map[uint64]int)
	for idx1 := range arr {
		for idx2 := range arr[idx1] {
			// how many times have we encountered this elem?
			if _, ok := tempMap[arr[idx1][idx2]]; ok {
				tempMap[arr[idx1][idx2]]++
			} else {
				tempMap[arr[idx1][idx2]] = 1
			}
		}
	}

	// find the keys equal to the length of the input args
	tempArray := make([]uint64, 0)
	for key, val := range tempMap {
		if val == arrLength {
			tempArray = append(tempArray, key)
		}
	}

	return tempArray
}
396984
func repeat(r rune, c int) []rune {
	if c > MaxPrefixSize {
		c = MaxPrefixSize
	}

	ret := make([]rune, c)

	// binary growth using copy for speed
	ret[0] = r
	bp := 1
	for bp < len(ret) {
		copy(ret[bp:], ret[:bp])
		bp *= 2
	}

	return ret
}
591120
@Override
    public ListT<W,T> distinct() {

        return (ListT<W,T>) FoldableTransformerSeq.super.distinct();
    }
869669
func uniqueMorphism() morphism {
	return morphism{
		Reversal: func(ctx *pathContext) (morphism, *pathContext) { return uniqueMorphism(), ctx },
		Apply: func(in shape.Shape, ctx *pathContext) (shape.Shape, *pathContext) {
			return shape.Unique{in}, ctx
		},
	}
}
812183
func (p *pathObject) Unique() *pathObject {
	np := p.clonePath().Unique()
	return p.new(np)
}
1162571
func (s *Sequence) Next() (uint64, error) {
	s.current += s.increment

	// Check for missed minimum condition
	if s.current < s.minvalue {
		return 0, errors.New("reached minimum bound of the sequence")
	}

	// Check for reached maximum condition
	if s.current > s.maxvalue {
		return 0, errors.New("reached maximum bound of sequence")
	}

	return s.current, nil
}