List of usage examples for java.util.stream Collectors counting
public static <T> Collector<T, ?, Long> counting()
From source file:Main.java
public static void main(String[] args) { System.out.println("counting " + Arrays.asList(1, 20, 40, 4).stream().collect(Collectors.counting())); }
From source file:Main.java
public static void main(String[] args) { Stream<String> s = Stream.of("1", "2", "3"); long o = s.collect(Collectors.counting()); System.out.println(o);//from w w w.ja v a 2 s . c om }
From source file:Main.java
public static void main(String... args) { long o = Food.menu.stream().collect(Collectors.counting()); System.out.println(o); }
From source file:Main.java
public static void main(String[] args) { List<String> stringList = Arrays.asList("2", "1", "3", "4"); long m = stringList.stream().collect(Collectors.counting()); System.out.println(m);//from w w w . j a v a 2 s . co m }
From source file:Main.java
public static void main(String... args) { Map<Type, Long> t = Food.menu.stream().collect(Collectors.groupingBy(Food::getType, Collectors.counting())); System.out.println(t);// w ww . j av a 2 s .c om }
From source file:Main.java
public static void main(String[] args) { Map<Employee.Gender, Long> countByGender = Employee.persons().stream() .collect(Collectors.groupingBy(Employee::getGender, Collectors.counting())); System.out.println(countByGender); }
From source file:Main.java
public static void main(String[] args) { Map<Employee.Gender, Long> countByGender = Employee.persons().stream() .collect(Collectors.groupingByConcurrent(Employee::getGender, Collectors.counting())); System.out.println(countByGender); }
From source file:Main.java
/** * Returns a collector that computes the distribution of the provided elements. This effectively counts how many * times an item has appeared in a stream. * * @param <T>//from w w w. j a v a 2 s .c o m * the counted type * @return the distribution collector */ public static <T> Collector<T, ?, Map<T, Long>> distribution() { return Collectors.groupingBy(Function.identity(), Collectors.counting()); }
From source file:com.firewallid.util.FIUtils.java
public static <L> Map<L, Long> reduceListToMap(List<L> l) { Map<L, Long> map = l.parallelStream() .collect(Collectors.groupingBy(object -> object, Collectors.counting())); return map;/*from w w w . jav a2 s.co m*/ }
From source file:documents.DocumentProvider.java
public long documentsAvailable() { return docsAvailable.entrySet().stream().filter(s -> s.getValue() == 0).collect(Collectors.counting()); }