Skip to content

Commit 9598f9c

Browse files
authored
Make more deterministic with LinkedHashMaps and LinkedHashSets (#62)
1 parent e1e9370 commit 9598f9c

File tree

5 files changed

+158352
-158352
lines changed

5 files changed

+158352
-158352
lines changed

src/pcminer/Author.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package pcminer;
22

3-
import java.util.HashMap;
4-
import java.util.HashSet;
3+
import java.util.LinkedHashMap;
4+
import java.util.LinkedHashSet;
55
import java.util.Map;
66
import java.util.Set;
77

@@ -25,8 +25,8 @@ private Author(String name) {
2525
(name.indexOf(" ") != -1) ? name.substring(0, name.lastIndexOf(" ")).trim() : "";
2626
this.lastName =
2727
(name.indexOf(" ") != -1) ? name.substring(name.lastIndexOf(" ") + 1).trim() : name;
28-
this.publications = new HashSet<Publication>();
29-
this.committees = new HashSet<CommitteeRole>();
28+
this.publications = new LinkedHashSet<>();
29+
this.committees = new LinkedHashSet<>();
3030
}
3131

3232
public void addPublication(Publication pub) {
@@ -145,15 +145,15 @@ public String toJson(int indent) {
145145
private final Set<Publication> publications;
146146
private final Set<CommitteeRole> committees;
147147

148-
private static Map<String, String> nameMappings = new HashMap<String, String>();
149-
private static Map<Author, Author> authors = new HashMap<Author, Author>();
148+
private static Map<String, String> nameMappings = new LinkedHashMap<>();
149+
private static Map<Author, Author> authors = new LinkedHashMap<>();
150150

151151
public static void addNameMapping(String from, String to) {
152152
nameMappings.put(from, to);
153153
}
154154

155155
public static Set<Author> getAuthors() {
156-
return new HashSet<Author>(authors.keySet());
156+
return new LinkedHashSet<>(authors.keySet());
157157
}
158158

159159
public static int nrAuthors() {

src/pcminer/Conference.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package pcminer;
22

3-
import java.util.HashMap;
3+
import java.util.LinkedHashMap;
44
import java.util.Map;
55

66
public class Conference {
@@ -56,7 +56,7 @@ public String getName() {
5656
return name;
5757
}
5858

59-
private static Map<Conference, Conference> conferences = new HashMap<Conference, Conference>();
59+
private static Map<Conference, Conference> conferences = new LinkedHashMap<>();
6060

6161
private final String name;
6262
}

src/pcminer/ConferenceInstance.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package pcminer;
22

3-
import java.util.HashMap;
3+
import java.util.LinkedHashMap;
44
import java.util.Map;
55

66
public class ConferenceInstance {
@@ -80,7 +80,7 @@ public static int nrConferenceInstances() {
8080
}
8181

8282
private static final Map<ConferenceInstance, ConferenceInstance> conferenceInstances =
83-
new HashMap<ConferenceInstance, ConferenceInstance>();
83+
new LinkedHashMap<>();
8484

8585
private final Conference conference;
8686
private final String year;

0 commit comments

Comments
 (0)