func (q Query) Intersect(inputSlice T) (r Query) {
	if q.err != nil {
		r.err = q.err
		return
	}
	if inputSlice == nil {
		r.err = ErrNilInput
		return
	}

	in, ok := takeSliceArg(inputSlice)
	if !ok {
		r.err = ErrInvalidInput
		return
	}

	set := make(map[T]bool)
	intersection := make(map[T]bool)

	for _, v := range q.values {
		if _, ok := set[v]; !ok {
			set[v] = true
		}
	}
	for _, v := range in {
		if _, ok := set[v]; ok {
			delete(set, v)
			if _, added := intersection[v]; !added {
				intersection[v] = true
			}
		}
	}
	r.values = make([]T, len(intersection))
	i := 0
	for k := range intersection {
		r.values[i] = k
		i++
	}
	return
}
// Intersect returns set intersection of the source sequence and the
// provided input slice using default equality comparer. This is a set
// operation and may return an unordered sequence. inputSlice must be slice of
// a type although it looks like T, otherwise returns ErrInvalidInput.
//
// Example:
// 	both, err := From([]int{1,2,3,4,5}).Intersect([]int{3,4,5,6}).Results()
// 	// both is {3,4,5}
Intersect returns set intersection of the source sequence and the
provided input slice using default equality comparer. This is a set
operation and may return an unordered sequence. inputSlice must be slice of
a type although it looks like T, otherwise returns ErrInvalidInput.


// Intersect returns set intersection of the source sequence and the // provided input slice using default equality comparer . This is a set // operation and may return an unordered sequence . inputSlice must be slice of // a type although it looks like T otherwise returns ErrInvalidInput . // // Example : // both err : = From ( [] int { 1 2 3 4 5 } ) . Intersect ( [] int { 3 4 5 6 } ) . Results () // // both is { 3 4 5 }
func (q Query) Intersect(inputSlice T) (r Query) {
	if q.err != nil {
		r.err = q.err
		return
	}
	if inputSlice == nil {
		r.err = ErrNilInput
		return
	}
	in, ok := takeSliceArg(inputSlice)
	if !ok {
		r.err = ErrInvalidInput
		return
	}
	set := make(map[T]bool)
	intersection := make(map[T]bool)
	for _, v := range q.values {
		if _, ok := set[v]; !ok {
			set[v] = true
		}
	}
	for _, v := range in {
		if _, ok := set[v]; ok {
			delete(set, v)
			if _, added := intersection[v]; !added {
				intersection[v] = true
			}
		}
	}
	r.values = make([]T, len(intersection))
	i := 0
	for k := range intersection {
		r.values[i] = k
		i++
	}
	return
}
func ( q Query ) Intersect ( inputSlice T ) ( r Query ) { if q . err != nil { r . err = q . err return } if inputSlice == nil { r . err = ErrNilInput return } in , ok := takeSliceArg ( inputSlice ) if ! ok { r . err = ErrInvalidInput return } set := make ( map [ T ] bool ) intersection := make ( map [ T ] bool ) for _ , v := range q . values { if _ , ok := set [ v ] ; ! ok { set [ v ] = true } } for _ , v := range in { if _ , ok := set [ v ] ; ok { delete ( set , v ) if _ , added := intersection [ v ] ; ! added { intersection [ v ] = true } } } r . values = make ( [ ] T , len ( intersection ) ) i := 0 for k := range intersection { r . values [ i ] = k i ++ } return }
Intersect returns set intersection of the source sequence and the
provided input slice using default equality comparer.
Intersect returns set intersection of the source sequence and the provided input slice using default equality comparer .