Skip to content

Commit

Permalink
Ordered LinkedHashMap#hashCode() implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
pivovarit committed Aug 28, 2024
1 parent 5ba70a2 commit 62f5c00
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/vavr/collection/LinkedHashMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ public boolean equals(Object o) {

@Override
public int hashCode() {
return Collections.hashUnordered(this);
return Collections.hashOrdered(this);
}

private Object readResolve() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/io/vavr/collection/CollectionsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ private void forAll(List<Traversable<?>> traversables, boolean value) {
for (Traversable<?> traversable2 : traversables) {
if (traversable1 != traversable2) {
assertThat(traversable1.equals(traversable2)).isEqualTo(value);
if (value) {
if (value && traversable1.getClass().equals(traversable2.getClass())) {
assertThat(traversable1.hashCode() == traversable2.hashCode()).isTrue();
}
}
Expand Down

0 comments on commit 62f5c00

Please sign in to comment.