Refine search
private static Function<Page, Page> enforceLayoutProcessor(List<Symbol> expectedLayout, Map<Symbol, Integer> inputLayout) { int[] channels = expectedLayout.stream() .peek(symbol -> checkArgument(inputLayout.containsKey(symbol), "channel not found for symbol: %s", symbol)) .mapToInt(inputLayout::get) .toArray(); if (Arrays.equals(channels, range(0, inputLayout.size()).toArray())) { // this is an identity mapping return Function.identity(); } return new PageChannelSelector(channels); }
private static void testMapToInt() { System.out.println(); System.out.println("Test mapToInt start"); Collection<String> collection = Arrays.asList("a1", "a2", "a3", "a1"); // Delete first char of element and returns number int[] number = collection.stream().mapToInt((s) -> Integer.parseInt(s.substring(1))).toArray(); System.out.println("number = " + Arrays.toString(number)); // print number = [1, 2, 3, 1] }
/** * Input a line of numbers separated by space as integers * and return ArrayList of Integers. * eg. the String "1 2 3 4 5 6 7 8 9" is returned as an ArrayList of Integers. * * @param numbers range of numbers separated by space as a string * @return ArrayList of Integers */ public static int[] stringToIntegers(String numbers) { return Arrays.stream(numbers.split(" ")).mapToInt(Integer::parseInt).toArray(); }
private static int[] computeIndexesToMap( List<FieldSignature> inputSignature ) { ArrayList<Integer> integers = new ArrayList<>(); for ( int i = 0; i < inputSignature.size(); i++ ) { if ( inputSignature.get( i ).needsMapping() ) { integers.add( i ); } } return integers.stream().mapToInt( i -> i ).toArray(); } }
@Override public int[] fetchSegments(String processorName) { EntityManager entityManager = entityManagerProvider.getEntityManager(); final List<Integer> resultList = entityManager.createQuery( "SELECT te.segment FROM TokenEntry te " + "WHERE te.processorName = :processorName ORDER BY te.segment ASC", Integer.class ).setParameter("processorName", processorName).getResultList(); return resultList.stream().mapToInt(i -> i).toArray(); }
/** * Returns specified number of unique, randomly unused pids between {@code lowerBound} (inclusive) * and {@code upperBound} (inclusive). */ public int[] findAvailablePids(final int number) throws TimeoutException { Set<Integer> pids = new HashSet<>(); while (pids.size() < number) { int pid = new AvailablePid().findAvailablePid(); if (!pids.contains(pid)) { pids.add(pid); } } return Arrays.stream(pids.toArray(new Integer[0])).mapToInt(Integer::intValue).toArray(); }
SerializableCallGraph build(DefaultCallGraph cg) { SerializableCallGraph scg = new SerializableCallGraph(); scg.nodeIndexes = cg.nodes.values().stream() .mapToInt(this::getNode) .toArray(); scg.fieldAccessIndexes = cg.fieldAccessSites.values().stream() .flatMapToInt(accessSites -> accessSites.stream().mapToInt(this::getFieldAccess)) .toArray(); while (step()) { // just repeat } scg.nodes = nodes.toArray(new SerializableCallGraph.Node[0]); scg.callSites = callSites.toArray(new SerializableCallGraph.CallSite[0]); scg.fieldAccessList = fieldAccessList.toArray(new SerializableCallGraph.FieldAccess[0]); return scg; }
boolean processNodes() { boolean hasAny = false; for (DefaultCallGraphNode node : nodesToProcess.toArray(new DefaultCallGraphNode[0])) { int index = nodeToIndex.get(node); SerializableCallGraph.Node serializableNode = nodes.get(index); serializableNode.method = node.getMethod(); serializableNode.callSites = node.getCallSites().stream() .mapToInt(this::getCallSite) .toArray(); serializableNode.callerCallSites = node.getCallerCallSites().stream() .mapToInt(this::getCallSite) .toArray(); serializableNode.fieldAccessSites = node.getFieldAccessSites().stream() .mapToInt(this::getFieldAccess) .toArray(); hasAny = true; } nodesToProcess.clear(); return hasAny; }
private static boolean isHadoopVersionGreaterThanOrEquals(final int major, final int minor) { final String[] splitVersion = VersionInfo.getVersion().split("\\."); final int[] versions = Arrays.stream(splitVersion).mapToInt(Integer::parseInt).toArray(); return versions[0] >= major && versions[1] >= minor; }