Skip to content

Commit 2e439d7

Browse files
committed
MapValue по умолчанию сохраняет порядок элементов
1 parent d8fde24 commit 2e439d7

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/java/com/annimon/ownlang/lib/MapValue.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
package com.annimon.ownlang.lib;
22

33
import com.annimon.ownlang.exceptions.TypeException;
4-
import java.util.HashMap;
54
import java.util.Iterator;
5+
import java.util.LinkedHashMap;
66
import java.util.Map;
77
import java.util.Objects;
88
import java.util.function.Consumer;
@@ -25,7 +25,7 @@ public static MapValue merge(MapValue map1, MapValue map2) {
2525
private final Map<Value, Value> map;
2626

2727
public MapValue(int size) {
28-
this.map = new HashMap<>(size);
28+
this.map = new LinkedHashMap<>(size);
2929
}
3030

3131
public MapValue(Map<Value, Value> map) {
@@ -84,6 +84,10 @@ public void set(String key, Function function) {
8484
public void set(Value key, Value value) {
8585
map.put(key, value);
8686
}
87+
88+
public Map<Value, Value> getMap() {
89+
return map;
90+
}
8791

8892
@Override
8993
public Object raw() {

0 commit comments

Comments
 (0)