Example usage for com.google.common.primitives Ints toArray

List of usage examples for com.google.common.primitives Ints toArray

Introduction

In this page you can find the example usage for com.google.common.primitives Ints toArray.

Prototype

public static int[] toArray(Collection<? extends Number> collection) 

Source Link

Document

Returns an array containing each value of collection , converted to a int value in the manner of Number#intValue .

Usage

From source file:scipy.sparse.CSRMatrixUtil.java

static public int[] getShape(CSRMatrix matrix) {
    Object[] shape = matrix.getShape();

    List<? extends Number> values = (List) Arrays.asList(shape);

    return Ints.toArray(ValueUtil.asIntegers(values));
}

From source file:com.enonic.cms.framework.util.TIntObjectHashMap.java

public int[] keys() {
    return Ints.toArray(this.map.keySet());
}

From source file:se.kth.id1020.DoublingRatio.java

private static double timeTrial(int N, SumHandler handler) {
    int MAX = 10000000;
    Set<Integer> numbers = Sets.newHashSetWithExpectedSize(N);
    while (numbers.size() < N) {
        numbers.add(StdRandom.uniform(-MAX, MAX));
    }/*from w ww . ja v  a 2  s  . c  o m*/
    Stopwatch timer = new Stopwatch();
    int cnt = handler.count(Ints.toArray(numbers));
    return timer.elapsedTime();
}

From source file:com.enonic.cms.framework.util.TIntHashSet.java

public int[] toArray() {
    return Ints.toArray(this.set);
}

From source file:org.apache.calcite.util.IntList.java

/**
 * Converts a list of {@link Integer} objects to an array of primitive
 * <code>int</code>s.//  w  w w  . j  a  va 2s .com
 *
 * @param integers List of Integer objects
 * @return Array of primitive <code>int</code>s
 *
 * @deprecated Use {@link Ints#toArray(java.util.Collection)}
 */
@Deprecated // to be removed before 2.0
public static int[] toArray(List<Integer> integers) {
    return Ints.toArray(integers);
}

From source file:com.enonic.cms.framework.util.TIntArrayList.java

public int[] toArray() {
    return Ints.toArray(this.list);
}

From source file:uk.co.blackpepper.support.spring.jdbc.jooq.SpringJdbcJooqUtils.java

@VisibleForTesting
static int[] getSqlTypes(Collection<? extends Param<?>> params) {
    List<Integer> types = new ArrayList<>(params.size());

    for (Param<?> param : params) {
        types.add(javaTypeToSqlParameterType(param.getType()));
    }/*ww  w.j  a v  a2  s  .c om*/

    return Ints.toArray(types);
}

From source file:kungfu.algdesign.util.Utils.java

public static int[] getIntArray(InputStream inputStream) throws IOException {
    InputStreamReader inputStreamReader = new InputStreamReader(inputStream);

    BufferedReader bufferedReader = new BufferedReader(inputStreamReader);

    List<Integer> integerList = new ArrayList<>();

    String line = null;/*from w w w.j  a v a  2s . c o  m*/

    while ((line = bufferedReader.readLine()) != null) {
        integerList.add(Integer.valueOf(line));
    }

    return Ints.toArray(integerList);
}

From source file:common.Utilities.java

public static List<int[]> createRandomBaseline(int from, int to, int count) {
    List<int[]> baseline = new ArrayList<int[]>();

    for (int i = 0; i < count; i++) {
        baseline.add(Ints.toArray(getRandomIndices(from, to)));
    }// w  w  w .jav  a  2  s  .  c  o  m

    return baseline;
}

From source file:com.google.android.apps.forscience.whistlepunk.audiogen.voices.PitchGenerator.java

public static int[] generatePitches(int scale[], int pitchMin, int pitchMax) {
    ArrayList<Integer> pitches = new ArrayList<>();

    for (int pitch = pitchMin; pitch <= pitchMax; pitch += 12) {
        for (int i = 0; i < scale.length; i++) {
            if (pitch + scale[i] > pitchMax) {
                break;
            }//from w ww  . j a  va  2 s  .  co  m
            pitches.add(pitch + scale[i]);
        }
    }

    return Ints.toArray(pitches);
}