Skip to content

Commit

Permalink
Merge pull request #1657 from ruslansennov/hotfix1656
Browse files Browse the repository at this point in the history
Fixes LinkedHashMap::values() #1656
  • Loading branch information
danieldietrich authored Nov 2, 2016
2 parents cfb4f0f + 6466e98 commit 1cc8b83
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ public java.util.LinkedHashMap<K, V> toJavaMap() {

@Override
public Seq<V> values() {
return map.values();
return map(t -> t._2);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,14 @@ protected <K extends Comparable<? super K>, V> LinkedHashMap<K, V> mapFill(int n

@Test
public void shouldKeepOrder() {
CharSeq actual = LinkedHashMap.<Integer, Character> empty().put(3, 'a').put(2, 'b').put(1, 'c').foldLeft(CharSeq.empty(), (s, t) -> s.append(t._2));
assertThat(actual).isEqualTo(CharSeq.of("abc"));
List<Character> actual = LinkedHashMap.<Integer, Character> empty().put(3, 'a').put(2, 'b').put(1, 'c').foldLeft(List.empty(), (s, t) -> s.append(t._2));
Assertions.assertThat(actual).isEqualTo(List.of('a', 'b', 'c'));
}

@Test
public void shouldKeepValuesOrder() {
List<Character> actual = LinkedHashMap.<Integer, Character> empty().put(3, 'a').put(2, 'b').put(1, 'c').values().foldLeft(List.empty(), List::append);
Assertions.assertThat(actual).isEqualTo(List.of('a', 'b', 'c'));
}

// -- static narrow
Expand Down

0 comments on commit 1cc8b83

Please sign in to comment.