List of usage examples for java.util Vector.Builder set
public synchronized E set(int index, E element)
From source file:org.briljantframework.data.Collectors.java
public static <T> Collector<T, ?, Vector> valueCounts() { return Collector.of(HashMap::new, (map, t) -> map.compute(t, (v, c) -> c == null ? 1 : c + 1), new BinaryOperator<HashMap<T, Integer>>() { @Override/*ww w . ja v a 2 s .c om*/ public HashMap<T, Integer> apply(HashMap<T, Integer> left, HashMap<T, Integer> right) { right.forEach((k, v) -> left.merge(k, v, (Integer o, Integer n) -> o == null ? n : o + n)); return left; } }, (map) -> { Vector.Builder b = new TypeInferenceVectorBuilder(); for (Map.Entry<T, Integer> e : map.entrySet()) { b.set(e.getKey(), e.getValue()); } return b.build(); }, Collector.Characteristics.UNORDERED); }
From source file:org.briljantframework.data.vector.AbstractVector.java
@Override public <T> Vector filterWithIndex(Class<T> cls, BiPredicate<Object, ? super T> predicate) { Vector.Builder builder = newBuilder(); for (Object key : getIndex()) { T value = get(cls, key);/* ww w. j a v a 2s .com*/ if (predicate.test(key, value)) { builder.set(key, value); } } return builder.build(); }
From source file:org.briljantframework.data.vector.AbstractVector.java
@Override public <T> Vector map(Class<T> cls, Function<? super T, ?> operator) { Vector.Builder builder = new TypeInferenceVectorBuilder(); for (Object key : this.getIndex()) { builder.set(key, operator.apply(get(cls, key))); }/*from ww w . j av a2 s . co m*/ return builder.build(); }
From source file:org.briljantframework.data.vector.AbstractVector.java
@Override public <T> Vector mapWithIndex(Class<T> cls, BiFunction<Object, ? super T, ?> operator) { Vector.Builder builder = new TypeInferenceVectorBuilder(); for (Object key : this.getIndex()) { builder.set(key, operator.apply(key, get(cls, key))); }/* w ww . java 2s . c om*/ return builder.build(); }