List of usage examples for org.apache.commons.lang3 ArrayUtils toObject
public static Boolean[] toObject(final boolean[] array)
Converts an array of primitive booleans to objects.
This method returns null for a null input array.
From source file:eu.learnpad.simulator.utils.SimpleMarkovModel.java
public static void main(String[] args) { // simple example SimpleMarkovModel<Character> m = new SimpleMarkovModel<Character>(2, '#'); m.addSeries(ArrayUtils.toObject("aabbbccccaaabbc".toCharArray())); System.out.println(m);//from w w w .j a v a2 s . co m int nbA = 0; int nbC = 0; for (int i = 0; i < 1000000; i++) { Character v = m.draw(ArrayUtils.toObject("cc".toCharArray())); if (v == 'a') { nbA++; } else { nbC++; } } System.out.println("draw 'a' " + nbA + " times"); System.out.println("draw 'c' " + nbC + " times"); }
From source file:br.ufpr.inf.gres.utils.TestCaseUtils.java
/** * Get the test cases selected indexes in relation the test case set * * @param testCasesSelected The test cases that I want discovery the indexes * @param testCases The test cases set/*from www . j av a 2s . co m*/ * @return * @throws TestCaseSetSelectionException */ public static List<Integer> getVariables(List<String> testCasesSelected, List<TestCase> testCases) throws TestCaseSetSelectionException { return Arrays.asList(ArrayUtils.toObject(IntStream.range(0, testCases.size()) .filter(i -> testCasesSelected.contains(testCases.get(i).getDescription())).toArray())); }
From source file:es.ua.impact.utils.EditDistanceAligner.java
static public int getEditDistance(String w1, String w2) { int ret;//from w ww . j a v a2 s. c o m String w = getKey(w1, w2); if (alignments.containsKey(w)) { ret = alignments.get(w).distance; } else { int[] alignment = new int[w1.length()]; ret = EditDistanceAligner.editDistance(Arrays.asList(ArrayUtils.toObject(w1.toCharArray())), Arrays.asList(ArrayUtils.toObject(w2.toCharArray())), alignment); alignments.put(w, new AlignmentData(w, alignment, ret)); } return ret; }
From source file:net.sf.gazpachoquest.dto.answers.LongTextAnswer.java
@Override public Character[] getValue() { return ArrayUtils.toObject(value.toCharArray()); }
From source file:dk.netdesign.common.osgi.config.filters.StringToCharacterArrayFilter.java
@Override public Character[] parse(String input) throws TypeFilterException { char[] charArray = input.toCharArray(); return ArrayUtils.toObject(charArray); }
From source file:edu.snu.dolphin.dnn.util.NeuralNetworkUtils.java
/** * Converts an array of {@code int}s for a shape to a string. * @param dimensions an array of {@code int}s for a shape. * @return a string for a shape./*from w ww . ja va 2 s .co m*/ */ public static String shapeToString(final int[] dimensions) { return shapeToString(Arrays.asList(ArrayUtils.toObject(dimensions))); }
From source file:es.ua.impact.utils.EditDistanceAligner.java
static public int[] getAlignment(String w1, String w2) { int[] ret;// w ww.jav a 2 s.c o m String w = getKey(w1, w2); if (alignments.containsKey(w)) { ret = alignments.get(w).alignment; } else { ret = new int[w2.length()]; int d = EditDistanceAligner.editDistance(Arrays.asList(ArrayUtils.toObject(w1.toCharArray())), Arrays.asList(ArrayUtils.toObject(w2.toCharArray())), ret); alignments.put(w, new AlignmentData(w, ret, d)); } return ret; }
From source file:com.fizzed.rocker.runtime.CollectionForIterator.java
public CollectionForIterator(int[] a) { this(ArrayUtils.toObject(a)); }
From source file:com.linkedin.pinot.operator.filter.OrOperatorTest.java
@Test public void testUnionForTwoLists() { int[] docIds1 = new int[] { 2, 3, 10, 15, 16, 28 }; int[] docIds2 = new int[] { 3, 6, 8, 20, 28 }; TreeSet<Integer> treeSet = new TreeSet<>(); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds1))); treeSet.addAll(Arrays.asList(ArrayUtils.toObject(docIds2))); Iterator<Integer> expectedIterator = treeSet.iterator(); List<BaseFilterOperator> operators = new ArrayList<>(); operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds1)); operators.add(FilterOperatorTestUtils.makeFilterOperator(docIds2)); OrOperator orOperator = new OrOperator(operators); BlockDocIdIterator iterator = orOperator.nextBlock().getBlockDocIdSet().iterator(); int docId;/*from www . j ava 2 s. co m*/ while ((docId = iterator.next()) != Constants.EOF) { Assert.assertEquals(docId, expectedIterator.next().intValue()); } }
From source file:com.google.mr4c.serialize.bean.metadata.MetadataArrayBeanTest.java
private void buildByteArray() { byte[] bytes = new byte[] { 55, 66, -125, 0 }; Byte[] byteObjs = ArrayUtils.toObject(bytes); m_byteArray = new MetadataArray(byteObjs, PrimitiveType.BYTE); }