static <T> MSeq<T> of(final Iterable<? extends T> values) {
		requireNonNull(values);

		@SuppressWarnings("unchecked")
		final Iterable<T> vals = (Iterable<T>)values;
		return switch (vals) {
            case ISeq<T> seq -> seq.isEmpty() ? empty() : seq.copy();
            case MSeq<T> seq -> seq.isEmpty() ? empty() : MSeq.of(seq);
			case BaseSeq<T> seq -> seq.isEmpty()
				? empty()
				: MSeq.<T>ofLength(seq.length()).setAll(values);
            case Collection<T> coll -> coll.isEmpty()
	                ? empty()
	                : MSeq.<T>ofLength(coll.size()).setAll(values);
            default -> {
                final Stream.Builder<T> builder = Stream.builder();
                values.forEach(builder::add);
                final Object[] objects = builder.build().toArray();

                yield objects.length == 0
	                ? empty()
	                : new ArrayMSeq<>(Array.of(ObjectStore.of(objects)));
            }
        };
	}
Create a new {@code MSeq} from the given values.

@param <T> the element type
@param values the array values.
@return a new {@code MSeq} with the given values.
@throws NullPointerException if the {@code values} object is
       {@code null}.
jenetics/src/main/java/io/jenetics/util/MSeq.java