###### tags: Traitement Parallèle de Données # Interface fonctionnelle | Interface fonctionnelle | utilité | terminal | |:-----------------------:|:---------:|:--------:| | Predicate<T> | filtrer | non | | Consumer<T> | foreach | oui | | BinaryOperator<T> | reduction | oui | | UnaryOperator<T> | reduction | oui | | IntBinaryOperator | reduction | oui | | IntUnaryOperator | reduction | oui | | DoubleUnaryOperator | reduction | oui | | DoubleBinaryOperator | reduction | oui | | Function<T1,T2> | map | non | | ToIntFunction<T1> | map | non | | BiFunction<T1, T2, T3> | map | non | ## Opérateur default DoubleBinaryOperator = BiFunction<Double, Double> -> ainsi plus besoin d'avoir de wrapper ## Stream ```java= Stream<Integer> stream = list.stream(); ``` Un `Stream`, une fois employé, n'existe plus. Par exemple en écrivant : `size = stream.count();` On ne peut plus employé la variable stream. Pour simplifier les Stream : mapToInt -> IntStream - même chose pour tous les autres types simples mapToInt(...).sum() Methods terminales : - reduce, count, collect, toArray, forEach Methodes non-terminales : - sorted, mapToInt, map, Integer:: -> sum, compare, Moyen mnémotechnique pour se rappeler des méthodes dans Collectors : même chose que dans Stream, mais avec -ing -> - exemple : - reduce -> reducing `IntFunction<Integer[]> tabGenerator = Integer[]::new;`