Skip to content

Commit f938c80

Browse files
committed
Replace HashMap with LinkedHashMap to ensure order
This makes it easier to unit test, as the order of the constraints in queries are now guranateed. I can't come up with a better solution. The performance characteristics of LinkedHashMap and HashMap are similar, so this should not make too much of a difference in runtime.
1 parent 9c26f41 commit f938c80

1 file changed

Lines changed: 2 additions & 5 deletions

File tree

src/main/java/com/formulasearchengine/mathmlquerygenerator/XQueryGenerator.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@
1111

1212
import javax.xml.parsers.ParserConfigurationException;
1313
import java.io.IOException;
14-
import java.util.ArrayList;
15-
import java.util.HashMap;
16-
import java.util.Iterator;
17-
import java.util.Map;
14+
import java.util.*;
1815
import java.util.regex.Pattern;
1916

2017
import static com.formulasearchengine.xmlhelper.NonWhitespaceNodeList.getFirstChild;
@@ -32,7 +29,7 @@
3229
public class XQueryGenerator {
3330
private static final Pattern ANNOTATION_XML_PATTERN = Pattern.compile( "annotation(-xml)?" );
3431
//Qvar map of qvar name to XPaths referenced by each qvar
35-
private Map<String, ArrayList<String>> qvar = new HashMap<>();
32+
private Map<String, ArrayList<String>> qvar = new LinkedHashMap<>();
3633
private String relativeXPath = "";
3734
private String exactMatchXQuery = "";
3835
private String lengthConstraint = "";

0 commit comments

Comments
 (0)