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/actions
Files:
4 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,
Note: See TracChangeset for help on using the changeset viewer.