func (q Query) Join(innerSlice T,
	outerKeySelector func(T) T,
	innerKeySelector func(T) T,
	resultSelector func(
		outer T,
		inner T) T) (r Query) {
	if q.err != nil {
		r.err = q.err
		return
	}
	if innerSlice == nil {
		r.err = ErrNilInput
		return
	}
	innerCollection, ok := takeSliceArg(innerSlice)
	if !ok {
		r.err = ErrInvalidInput
		return
	}
	if outerKeySelector == nil || innerKeySelector == nil || resultSelector == nil {
		r.err = ErrNilFunc
		return
	}
	var outerCollection = q.values
	innerKeyLookup := make(map[T]T)

	for _, outer := range outerCollection {
		outerKey := outerKeySelector(outer)
		for _, inner := range innerCollection {
			innerKey, ok := innerKeyLookup[inner]
			if !ok {
				innerKey = innerKeySelector(inner)
				innerKeyLookup[inner] = innerKey
			}
			if innerKey == outerKey {
				elem := resultSelector(outer, inner)
				r.values = append(r.values, elem)
			}
		}
	}
	return
}
// Join correlates the elements of two sequences based on the equality of keys.
// Inner and outer keys are matched using default equality comparer, ==.
//
// Outer collection is the original sequence.
//
// Inner collection is the one provided as innerSlice input parameter as slice
// of any type. Otherwise returns ErrInvalidInput.
//
// outerKeySelector extracts a key from outer element for comparison.
//
// innerKeySelector extracts a key from outer element for comparison.
//
// resultSelector takes outer element and inner element as inputs
// and returns a value which will be an element in the resulting query.
Join correlates the elements of two sequences based on the equality of keys.
Inner and outer keys are matched using default equality comparer, ==.

Outer collection is the original sequence.

Inner collection is the one provided as innerSlice input parameter as slice
of any type. Otherwise returns ErrInvalidInput.

outerKeySelector extracts a key from outer element for comparison.

innerKeySelector extracts a key from outer element for comparison.

resultSelector takes outer element and inner element as inputs
and returns a value which will be an element in the resulting query.
// Join correlates the elements of two sequences based on the equality of keys . // Inner and outer keys are matched using default equality comparer == . // // Outer collection is the original sequence . // // Inner collection is the one provided as innerSlice input parameter as slice // of any type . Otherwise returns ErrInvalidInput . // // outerKeySelector extracts a key from outer element for comparison . // // innerKeySelector extracts a key from outer element for comparison . // // resultSelector takes outer element and inner element as inputs // and returns a value which will be an element in the resulting query .
func (q Query) Join(innerSlice T,
	outerKeySelector func(T) T,
	innerKeySelector func(T) T,
	resultSelector func(
		outer T,
		inner T) T) (r Query) {
	if q.err != nil {
		r.err = q.err
		return
	}
	if innerSlice == nil {
		r.err = ErrNilInput
		return
	}
	innerCollection, ok := takeSliceArg(innerSlice)
	if !ok {
		r.err = ErrInvalidInput
		return
	}
	if outerKeySelector == nil || innerKeySelector == nil || resultSelector == nil {
		r.err = ErrNilFunc
		return
	}
	var outerCollection = q.values
	innerKeyLookup := make(map[T]T)
	for _, outer := range outerCollection {
		outerKey := outerKeySelector(outer)
		for _, inner := range innerCollection {
			innerKey, ok := innerKeyLookup[inner]
			if !ok {
				innerKey = innerKeySelector(inner)
				innerKeyLookup[inner] = innerKey
			}
			if innerKey == outerKey {
				elem := resultSelector(outer, inner)
				r.values = append(r.values, elem)
			}
		}
	}
	return
}
func ( q Query ) Join ( innerSlice T , outerKeySelector func ( T ) T , innerKeySelector func ( T ) T , resultSelector func ( outer T , inner T ) T ) ( r Query ) { if q . err != nil { r . err = q . err return } if innerSlice == nil { r . err = ErrNilInput return } innerCollection , ok := takeSliceArg ( innerSlice ) if ! ok { r . err = ErrInvalidInput return } if outerKeySelector == nil || innerKeySelector == nil || resultSelector == nil { r . err = ErrNilFunc return } var outerCollection = q . values innerKeyLookup := make ( map [ T ] T ) for _ , outer := range outerCollection { outerKey := outerKeySelector ( outer ) for _ , inner := range innerCollection { innerKey , ok := innerKeyLookup [ inner ] if ! ok { innerKey = innerKeySelector ( inner ) innerKeyLookup [ inner ] = innerKey } if innerKey == outerKey { elem := resultSelector ( outer , inner ) r . values = append ( r . values , elem ) } } } return }
Join correlates the elements of two sequences based on the equality of keys.
Join correlates the elements of two sequences based on the equality of keys .