aboutsummaryrefslogtreecommitdiffstats
path: root/lib/jinterface/java_src/com
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2015-12-07 16:04:29 +0100
committerHenrik Nord <[email protected]>2015-12-07 16:04:29 +0100
commit4e7d93de5f0aa04e6a9c67ee9a16e0f34987c846 (patch)
treebb8486ef782a20286c24e66d0e6863318972ce49 /lib/jinterface/java_src/com
parent75b185358f5c901e57bbeab1e60caf4e4aa28ca9 (diff)
parentff76dce72f52c5fd2d06461414dac52a70ba43cc (diff)
downloadotp-4e7d93de5f0aa04e6a9c67ee9a16e0f34987c846.tar.gz
otp-4e7d93de5f0aa04e6a9c67ee9a16e0f34987c846.tar.bz2
otp-4e7d93de5f0aa04e6a9c67ee9a16e0f34987c846.zip
Merge branch 'vladdu/jinterface_map_sortkeys' into maint
* vladdu/jinterface_map_sortkeys: Improve sorting order of keys in a map
Diffstat (limited to 'lib/jinterface/java_src/com')
-rw-r--r--lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangMap.java23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangMap.java b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangMap.java
index 0fd7d3ce37..30126db3fd 100644
--- a/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangMap.java
+++ b/lib/jinterface/java_src/com/ericsson/otp/erlang/OtpErlangMap.java
@@ -19,7 +19,7 @@
*/
package com.ericsson.otp.erlang;
-import java.util.HashMap;
+import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
@@ -37,13 +37,22 @@ public class OtpErlangMap extends OtpErlangObject {
// don't change this!
private static final long serialVersionUID = -6410770117696198497L;
- private HashMap<OtpErlangObject, OtpErlangObject> map;
+ private OtpMap map;
+
+ private static class OtpMap
+ extends LinkedHashMap<OtpErlangObject, OtpErlangObject> {
+ private static final long serialVersionUID = -2666505810905455082L;
+
+ public OtpMap() {
+ super();
+ }
+ }
/**
* Create an empty map.
*/
public OtpErlangMap() {
- map = new HashMap<OtpErlangObject, OtpErlangObject>();
+ map = new OtpMap();
}
/**
@@ -93,7 +102,7 @@ public class OtpErlangMap extends OtpErlangObject {
throw new java.lang.IllegalArgumentException(
"Map keys and values must have same arity");
}
- map = new HashMap<OtpErlangObject, OtpErlangObject>(vcount);
+ map = new OtpMap();
OtpErlangObject key, val;
for (int i = 0; i < vcount; i++) {
if ((key = keys[kstart + i]) == null) {
@@ -125,7 +134,7 @@ public class OtpErlangMap extends OtpErlangObject {
final int arity = buf.read_map_head();
if (arity > 0) {
- map = new HashMap<OtpErlangObject, OtpErlangObject>(arity);
+ map = new OtpMap();
for (int i = 0; i < arity; i++) {
OtpErlangObject key, val;
key = buf.read_any();
@@ -133,7 +142,7 @@ public class OtpErlangMap extends OtpErlangObject {
put(key, val);
}
} else {
- map = new HashMap<OtpErlangObject, OtpErlangObject>();
+ map = new OtpMap();
}
}
@@ -350,7 +359,7 @@ public class OtpErlangMap extends OtpErlangObject {
@SuppressWarnings("unchecked")
public Object clone() {
final OtpErlangMap newMap = (OtpErlangMap) super.clone();
- newMap.map = (HashMap<OtpErlangObject, OtpErlangObject>) map.clone();
+ newMap.map = (OtpMap) map.clone();
return newMap;
}
}