@Validate
public static <T, TKey extends Comparable<TKey>, TValue> AvlHashtable<TKey, TValue>
toAvlHashtable(@NotNull final T[] values, @NotNull final Function1<T, TKey> keySelector,
@NotNull final Function1<T, TValue> valueSelector)
{
val result = new AvlHashtable<TKey, TValue>(keySelector.getReturnType(), valueSelector.getReturnType());
val count = values.length;
for (int i = 0; i < count; i++)
result.add(keySelector.apply(values[i]), valueSelector.apply(values[i]));
return result;
}