List of usage examples for java.util.function IntUnaryOperator applyAsInt
int applyAsInt(int operand);
From source file:com.vmware.photon.controller.deployer.xenon.workflow.BatchCreateManagementWorkflowService.java
private List<Operation> getQuroumUpdateOperations(State currentState, Map<String, List<Pair<String, Integer>>> xenonServiceToIp, IntUnaryOperator computeQuorum) { String protocol = "http"; if (!BatchCreateManagementWorkflowService.inUnitTests && currentState.isAuthEnabled) { protocol = "https"; }/*w w w .j a v a2s . co m*/ List<Operation> quorumUpdates = new ArrayList<>(); for (Entry<String, List<Pair<String, Integer>>> entry : xenonServiceToIp.entrySet()) { UpdateQuorumRequest patch = new UpdateQuorumRequest(); patch.kind = UpdateQuorumRequest.KIND; patch.membershipQuorum = computeQuorum.applyAsInt(entry.getValue().size()); patch.isGroupUpdate = false; for (Pair<String, Integer> address : entry.getValue()) { quorumUpdates.add(Operation.createPatch(UriUtils.buildUri(protocol, address.getFirst(), address.getSecond(), ServiceUriPaths.DEFAULT_NODE_GROUP, null)).setBody(patch)); } } return quorumUpdates; }
From source file:gedi.util.ArrayUtils.java
/** * Increments the array para if possible. Incrementing an array means that the items * are interpreted as digits of a number with variable radix. * <p>Example with radix = 3,2: (0,0)->(1,0)->(2,0)->(0,1)->(1,1)->(2,1)->false * //from w w w . java2 s . co m * @param para the current number * @param radix the radix array * @return if the array could be incremented */ public static boolean increment(int[] para, int len, IntUnaryOperator radix) { int i; for (i = 0; i < len && para[i] >= radix.applyAsInt(i) - 1; i++) { para[i] = 0; } if (i < len) para[i]++; return i < len; }
From source file:org.briljantframework.array.AbstractIntArray.java
@Override public void assign(IntArray array, IntUnaryOperator operator) { Check.dimension(this, array); for (int i = 0; i < size(); i++) { set(i, operator.applyAsInt(array.get(i))); }//from w ww.j a v a2s.c om }
From source file:org.briljantframework.array.AbstractIntArray.java
@Override public void apply(IntUnaryOperator operator) { for (int i = 0; i < size(); i++) { set(i, operator.applyAsInt(get(i))); }//from ww w .j av a 2 s . c om }
From source file:org.briljantframework.array.AbstractIntArray.java
@Override public IntArray map(IntUnaryOperator operator) { IntArray mat = newEmptyArray(getShape()); for (int i = 0; i < size(); i++) { mat.set(i, operator.applyAsInt(get(i))); }//from w w w. j av a2s .c o m return mat; }
From source file:org.briljantframework.array.AbstractIntArray.java
@Override public int reduce(int identity, IntBinaryOperator reduce, IntUnaryOperator map) { for (int i = 0, size = size(); i < size; i++) { identity = reduce.applyAsInt(map.applyAsInt(get(i)), identity); }//from w ww . ja v a 2 s.c o m return identity; }
From source file:org.briljantframework.array.AbstractIntArray.java
@Override public void apply(int index, IntUnaryOperator operator) { set(index, operator.applyAsInt(get(index))); }
From source file:org.briljantframework.array.AbstractIntArray.java
@Override public void apply(int i, int j, IntUnaryOperator operator) { set(i, j, operator.applyAsInt(get(i, j))); }
From source file:sadl.models.TauPTA.java
private List<UntimedSequence> insertSequentialAnomaly(IntUnaryOperator f) { final Set<UntimedSequence> allSequences = getAllSequences(); final TObjectDoubleMap<UntimedSequence> sequenceProbabilities = computeEventProbabilities(allSequences); // this function may be one lamba with the streaming interface // List<UntimedSequence> abnormalSequences = getAllSequences().stream().sort(one way or the other depending on the type of anomaly).take First $K$ // elements.collect(as List) logger.debug("AllSequences.size()={}", allSequences.size()); logger.debug("Transitions.size()={}", getTransitionCount()); final Comparator<UntimedSequence> c = (s1, s2) -> { final int probCompare = Double.compare(sequenceProbabilities.get(s1), sequenceProbabilities.get(s2)); if (probCompare != 0) { return f.applyAsInt(probCompare); } else {//from ww w.j a va 2 s . c o m return f.applyAsInt(s1.toString().compareTo(s2.toString())); } }; logger.debug("Transitions.size()={}", transitions.size()); final int cap = Math.min(SEQUENTIAL_ANOMALY_K, allSequences.size()); return allSequences.stream().sorted(c).limit(cap).peek(s -> labelWithAnomaly(s, getAnomalyType())) .collect(Collectors.toList()); // allSequences.sort((t1, t2) -> Double.compare(sequenceProbabilities.get(t1), sequenceProbabilities.get(t2))); // final List<UntimedSequence> abnormalSequences = function.apply(allSequences); // abnormalSequences.forEach(s -> labelWithAnomaly(s,getAnomalyType())); }