Commit 016981c0 authored by Romain WALLON's avatar Romain WALLON

Merge branch 'master' of https://gitlab.ow2.org/sat4j/sat4j

parents 6738d0a2 b42710a4
Pipeline #7654 failed with stages
in 2 minutes and 42 seconds
......@@ -30,6 +30,7 @@
package org.sat4j.core;
import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.Iterator;
import java.util.NoSuchElementException;
......@@ -557,4 +558,21 @@ public final class Vec<T> implements IVec<T> {
public static <U> Vec<U> of(U... values) {
return new Vec<>(values);
}
/**
* Alternative way to create a vector, the Java 9+ way, from a standard Java
* collection.
*
* @param values
* a collection with an arbitrary number of values
* @return a new vector with those values
* @since 2.3.6
*/
public static <U> Vec<U> of(Collection<U> values) {
Vec<U> v = new Vec<>(values.size());
for (U u : values) {
v.push(u);
}
return v;
}
}
......@@ -30,6 +30,7 @@
package org.sat4j.core;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.NoSuchElementException;
......@@ -667,4 +668,21 @@ public final class VecInt implements IVecInt {
public static VecInt of(int... values) {
return new VecInt(values);
}
/**
* Alternative way to create a vector, the Java 9+ way, from a standard Java
* collection.
*
* @param values
* a collection with an arbitrary number of values
* @return a new vector with those values
* @since 2.3.6
*/
public static VecInt of(Collection<Integer> values) {
VecInt v = new VecInt(values.size());
for (Integer i : values) {
v.push(i);
}
return v;
}
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment