Changeset 8856 in josm for trunk/src/org


Ignore:
Timestamp:
2015-10-11T15:28:33+02:00 (4 years ago)
Author:
Don-vip
Message:

fix #11957 - partial revert of r8851 - do not replace Stack by ArrayDeque because of different iteration behaviour + add unit test

Location:
trunk/src/org/openstreetmap/josm
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r8855 r8856  
    88import java.awt.event.ActionEvent;
    99import java.awt.event.KeyEvent;
    10 import java.util.ArrayDeque;
    1110import java.util.ArrayList;
    1211import java.util.Collection;
    1312import java.util.Collections;
    14 import java.util.Deque;
    1513import java.util.LinkedHashMap;
    1614import java.util.LinkedHashSet;
     
    1917import java.util.Map;
    2018import java.util.Set;
     19import java.util.Stack;
    2120
    2221import javax.swing.JOptionPane;
     
    569568        }
    570569
    571         protected boolean isSpanningWay(Deque<NodePair> way) {
     570        protected boolean isSpanningWay(Stack<NodePair> way) {
    572571            return numUndirectedEges == way.size();
    573572        }
    574573
    575         protected List<Node> buildPathFromNodePairs(Deque<NodePair> path) {
     574        protected List<Node> buildPathFromNodePairs(Stack<NodePair> path) {
    576575            List<Node> ret = new LinkedList<>();
    577576            for (NodePair pair: path) {
     
    593592            if (startNode == null)
    594593                return null;
    595             Deque<NodePair> path = new ArrayDeque<>();
    596             Deque<NodePair> nextPairs  = new ArrayDeque<>();
     594            Stack<NodePair> path = new Stack<>();
     595            Stack<NodePair> nextPairs  = new Stack<>();
    597596            nextPairs.addAll(getOutboundPairs(startNode));
    598597            while (!nextPairs.isEmpty()) {
  • trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java

    r8851 r8856  
    88import java.awt.event.KeyEvent;
    99import java.io.IOException;
    10 import java.util.ArrayDeque;
    1110import java.util.Collection;
    12 import java.util.Deque;
    1311import java.util.HashSet;
    1412import java.util.Set;
     13import java.util.Stack;
    1514
    1615import javax.swing.JOptionPane;
     
    322321        protected void realRun() throws SAXException, IOException, OsmTransferException {
    323322            try {
    324                 Deque<OsmPrimitive> toCheck = new ArrayDeque<>();
     323                Stack<OsmPrimitive> toCheck = new Stack<>();
    325324                toCheck.addAll(getPrimitivesToCheckForParents());
    326325                Set<OsmPrimitive> checked = new HashSet<>();
  • trunk/src/org/openstreetmap/josm/actions/upload/CyclicUploadDependencyException.java

    r8851 r8856  
    44import static org.openstreetmap.josm.tools.I18n.tr;
    55
    6 import java.util.ArrayDeque;
    7 import java.util.Deque;
     6import java.util.ArrayList;
     7import java.util.List;
     8import java.util.Stack;
    89
    910import org.openstreetmap.josm.data.osm.Relation;
    1011
    1112public class CyclicUploadDependencyException extends Exception {
    12     private final Deque<Relation> cycle;
     13    private final Stack<Relation> cycle;
    1314
    14     public CyclicUploadDependencyException(Deque<Relation> cycle) {
     15    public CyclicUploadDependencyException(Stack<Relation> cycle) {
    1516        this.cycle = cycle;
    1617    }
     
    3334        sb.append(tr("Cyclic dependency between relations:"))
    3435          .append('[');
    35         for (Relation r : cycle) {
    36             if (sb.length() > 0) {
     36        for (int i = 0; i < cycle.size(); i++) {
     37            if (i > 0) {
    3738                sb.append(',');
    3839            }
    39             sb.append(formatRelation(r));
     40            sb.append(formatRelation(cycle.get(i)));
    4041        }
    4142        sb.append(']');
     
    4344    }
    4445
    45     public Deque<Relation> getCyclicUploadDependency() {
    46         return new ArrayDeque<>(cycle);
     46    public List<Relation> getCyclicUploadDependency() {
     47        return new ArrayList<>(cycle);
    4748    }
    4849}
  • trunk/src/org/openstreetmap/josm/actions/upload/RelationUploadOrderHook.java

    r8851 r8856  
    66import java.awt.BorderLayout;
    77import java.awt.Dimension;
    8 import java.util.ArrayList;
    9 import java.util.Deque;
    108import java.util.Iterator;
    119import java.util.List;
     
    6967     */
    7068    protected void warnCyclicUploadDependency(CyclicUploadDependencyException e) {
    71         Deque<Relation> dep = e.getCyclicUploadDependency();
    72         Relation last = dep.getLast();
     69        List<Relation> dep = e.getCyclicUploadDependency();
     70        Relation last = dep.get(dep.size() -1);
    7371        Iterator<Relation> it = dep.iterator();
    7472        while (it.hasNext()) {
     
    7977            }
    8078        }
    81         JPanel pnl = buildWarningPanel(new ArrayList<>(dep));
     79        JPanel pnl = buildWarningPanel(dep);
    8280        ExtendedDialog dialog = new ExtendedDialog(
    8381                Main.parent,
  • trunk/src/org/openstreetmap/josm/data/APIDataSet.java

    r8851 r8856  
    22package org.openstreetmap.josm.data;
    33
    4 import java.util.ArrayDeque;
    54import java.util.ArrayList;
    65import java.util.Collection;
    76import java.util.Collections;
    87import java.util.Comparator;
    9 import java.util.Deque;
    108import java.util.HashMap;
    119import java.util.HashSet;
     
    1412import java.util.Map;
    1513import java.util.Set;
     14import java.util.Stack;
    1615
    1716import org.openstreetmap.josm.actions.upload.CyclicUploadDependencyException;
     
    310309        }
    311310
    312         protected void visit(Deque<Relation> path, Relation current) throws CyclicUploadDependencyException {
     311        protected void visit(Stack<Relation> path, Relation current) throws CyclicUploadDependencyException {
    313312            if (path.contains(current)) {
    314313                path.push(current);
     
    329328            visited = new HashSet<>();
    330329            uploadOrder = new LinkedList<>();
    331             Deque<Relation> path = new ArrayDeque<>();
     330            Stack<Relation> path = new Stack<>();
    332331            for (Relation relation: relations) {
    333332                visit(path, relation);
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r8851 r8856  
    1111import java.nio.charset.StandardCharsets;
    1212import java.text.NumberFormat;
    13 import java.util.ArrayDeque;
    1413import java.util.ArrayList;
    1514import java.util.Collection;
    1615import java.util.Collections;
    1716import java.util.Date;
    18 import java.util.Deque;
    1917import java.util.HashSet;
    2018import java.util.LinkedList;
     
    2321import java.util.Map.Entry;
    2422import java.util.Set;
     23import java.util.Stack;
    2524import java.util.TreeMap;
    2625import java.util.concurrent.CopyOnWriteArrayList;
     
    650649    }
    651650
    652     private Deque<ZoomData> zoomUndoBuffer = new ArrayDeque<>();
    653     private Deque<ZoomData> zoomRedoBuffer = new ArrayDeque<>();
     651    private Stack<ZoomData> zoomUndoBuffer = new Stack<>();
     652    private Stack<ZoomData> zoomRedoBuffer = new Stack<>();
    654653    private Date zoomTimestamp = new Date();
    655654
  • trunk/src/org/openstreetmap/josm/gui/dialogs/FilterDialog.java

    r8851 r8856  
    99import java.awt.event.KeyEvent;
    1010import java.awt.event.MouseEvent;
    11 import java.util.ArrayDeque;
    1211import java.util.ArrayList;
    1312import java.util.Arrays;
    1413import java.util.Collection;
    15 import java.util.Deque;
    1614import java.util.HashSet;
    1715import java.util.List;
    1816import java.util.Set;
     17import java.util.Stack;
    1918
    2019import javax.swing.AbstractAction;
     
    292291        // Filters can use nested parent/child expression so complete tree is necessary
    293292        Set<OsmPrimitive> result = new HashSet<>();
    294         Deque<OsmPrimitive> stack = new ArrayDeque<>();
     293        Stack<OsmPrimitive> stack = new Stack<>();
    295294        stack.addAll(primitives);
    296295
  • trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java

    r8851 r8856  
    1212import java.io.IOException;
    1313import java.net.HttpURLConnection;
    14 import java.util.ArrayDeque;
    15 import java.util.Deque;
    1614import java.util.HashSet;
    1715import java.util.Iterator;
    1816import java.util.List;
    1917import java.util.Set;
     18import java.util.Stack;
    2019
    2120import javax.swing.AbstractAction;
     
    330329    class DownloadAllChildrenTask extends DownloadTask {
    331330        private final Relation relation;
    332         private final Deque<Relation> relationsToDownload;
     331        private final Stack<Relation> relationsToDownload;
    333332        private final Set<Long> downloadedRelationIds;
    334333
     
    336335            super(tr("Download relation members"), parent);
    337336            this.relation = r;
    338             relationsToDownload = new ArrayDeque<>();
     337            relationsToDownload = new Stack<>();
    339338            downloadedRelationIds = new HashSet<>();
    340339            relationsToDownload.push(this.relation);
  • trunk/src/org/openstreetmap/josm/io/GpxReader.java

    r8851 r8856  
    77import java.io.InputStream;
    88import java.io.Reader;
    9 import java.util.ArrayDeque;
    109import java.util.ArrayList;
    1110import java.util.Collection;
    12 import java.util.Deque;
    1311import java.util.HashMap;
    1412import java.util.LinkedList;
    1513import java.util.List;
    1614import java.util.Map;
     15import java.util.Stack;
    1716
    1817import javax.xml.parsers.ParserConfigurationException;
     
    6564        private GpxLink currentLink;
    6665        private Extensions currentExtensions;
    67         private Deque<State> states;
    68         private final Deque<String> elements = new ArrayDeque<>();
     66        private Stack<State> states;
     67        private final Stack<String> elements = new Stack<>();
    6968
    7069        private StringBuilder accumulator = new StringBuilder();
     
    7574        public void startDocument() {
    7675            accumulator = new StringBuilder();
    77             states = new ArrayDeque<>();
     76            states = new Stack<>();
    7877            data = new GpxData();
    7978        }
     
    477476        @Override
    478477        public void endDocument() throws SAXException  {
    479             if (!states.isEmpty())
     478            if (!states.empty())
    480479                throw new SAXException(tr("Parse error: invalid document structure for GPX document."));
    481480            Extensions metaExt = (Extensions) data.get(META_EXTENSIONS);
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r8851 r8856  
    44import java.io.IOException;
    55import java.io.InputStream;
    6 import java.util.ArrayDeque;
    76import java.util.ArrayList;
    87import java.util.Arrays;
    9 import java.util.Deque;
    108import java.util.HashMap;
    119import java.util.List;
    1210import java.util.Map;
    1311import java.util.Objects;
     12import java.util.Stack;
    1413
    1514import javax.xml.parsers.ParserConfigurationException;
     
    7372        private StringBuilder accumulator = new StringBuilder();
    7473
    75         private Deque<State> states;
     74        private Stack<State> states;
    7675
    7776        private List<ImageryInfo> entries;
     
    9695            accumulator = new StringBuilder();
    9796            skipEntry = false;
    98             states = new ArrayDeque<>();
     97            states = new Stack<>();
    9998            states.push(State.INIT);
    10099            entries = new ArrayList<>();
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r8851 r8856  
    1010import java.lang.reflect.Method;
    1111import java.lang.reflect.Modifier;
    12 import java.util.ArrayDeque;
    13 import java.util.Deque;
    1412import java.util.HashMap;
    1513import java.util.Iterator;
     
    1816import java.util.Locale;
    1917import java.util.Map;
     18import java.util.Stack;
    2019
    2120import javax.xml.XMLConstants;
     
    6564
    6665    private class Parser extends DefaultHandler {
    67         private Deque<Object> current = new ArrayDeque<>();
     66        private Stack<Object> current = new Stack<>();
    6867        private StringBuilder characters = new StringBuilder(64);
    6968
Note: See TracChangeset for help on using the changeset viewer.