Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use a Vector as accumulator of map.traverse (#1633) #1671

Merged
merged 1 commit into from
Nov 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion javaslang/src/main/java/javaslang/collection/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ default <U> U transform(Function<? super Map<K, V>, ? extends U> f) {

default <U> Seq<U> traverse(BiFunction<K, V, ? extends U> mapper) {
Objects.requireNonNull(mapper, "mapper is null");
return foldLeft(List.empty(), (acc, entry) -> acc.append(mapper.apply(entry._1, entry._2)));
return foldLeft(Vector.empty(), (acc, entry) -> acc.append(mapper.apply(entry._1, entry._2)));
}

default Tuple2<Seq<K>, Seq<V>> unzip() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ default <U> U transform(Function<? super Multimap<K, V>, ? extends U> f) {

default <U> Seq<U> traverse(BiFunction<K, V, ? extends U> mapper) {
Objects.requireNonNull(mapper, "mapper is null");
return foldLeft(List.empty(), (acc, entry) -> acc.append(mapper.apply(entry._1, entry._2)));
return foldLeft(Vector.empty(), (acc, entry) -> acc.append(mapper.apply(entry._1, entry._2)));
}

default <T1, T2> Tuple2<Seq<T1>, Seq<T2>> unzip(BiFunction<? super K, ? super V, Tuple2<? extends T1, ? extends T2>> unzipper) {
Expand Down