public static <TOuter, TInner, TKey extends Comparable<TKey>, TResult> TResult[]
join(@NotNull final TOuter[] outerValues, @NotNull final TInner[] innerValues,
@NotNull final Function1<TOuter, TKey> outerKeySelector, @NotNull final Function1<TInner, TKey> innerKeySelector,
@NotNull final Function2<TOuter, TInner, TResult> resultSelector)
{
val result = new ArrayList<TResult>(DEFAULT_LIST_SIZE);
val lookup = new AvlHashtable<TKey, TOuter>(outerKeySelector.getReturnType(), outerKeySelector.getReturnType());
for (TOuter value : outerValues)
{
TKey outerKey = outerKeySelector.apply(value);
lookup.add(outerKey, value);
}
for (TInner inner : innerValues)
{
TKey innerKey = innerKeySelector.apply(inner);
if (lookup.containsKey(innerKey))
{
TOuter outer = lookup.get(innerKey);
TResult res = resultSelector.apply(outer, inner);
result.add(res);
}
}