Ignore:
Timestamp:
2013-03-19T02:09:12+01:00 (11 years ago)
Author:
Don-vip
Message:

fix #8517 - Sort validator results (based on patch by windu.2b)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/MultiMap.java

    r4685 r5783  
    55import java.util.Collection;
    66import java.util.HashMap;
    7 import java.util.LinkedHashSet;
    87import java.util.List;
    98import java.util.Map;
    109import java.util.Map.Entry;
    1110import java.util.Set;
     11import java.util.TreeSet;
    1212
    1313/**
     
    2020public class MultiMap<A, B> {
    2121
    22     private final Map<A, LinkedHashSet<B>> map;
     22    private final Map<A, Set<B>> map;
    2323
    2424    public MultiMap() {
    25         map = new HashMap<A, LinkedHashSet<B>>();
     25        map = new HashMap<A, Set<B>>();
    2626    }
    2727
    2828    public MultiMap(int capacity) {
    29         map = new HashMap<A, LinkedHashSet<B>>(capacity);
     29        map = new HashMap<A, Set<B>>(capacity);
    3030    }
    3131
     
    3636     */
    3737    public void put(A key, B value) {
    38         LinkedHashSet<B> vals = map.get(key);
     38        Set<B> vals = map.get(key);
    3939        if (vals == null) {
    40             vals = new LinkedHashSet<B>();
     40            vals = new TreeSet<B>();
    4141            map.put(key, vals);
    4242        }
     
    5353        if (map.containsKey(key))
    5454            return;
    55         map.put(key, new LinkedHashSet<B>());
     55        map.put(key, new TreeSet<B>());
    5656    }
    5757
     
    6262     */
    6363    public void putAll(A key, Collection<B> values) {
    64         LinkedHashSet<B> vals = map.get(key);
     64        Set<B> vals = map.get(key);
    6565        if (vals == null) {
    66             vals = new LinkedHashSet<B>(values);
     66            vals = new TreeSet<B>(values);
    6767            map.put(key, vals);
    6868        }
     
    9191     * Like get, but returns an empty Set if nothing has been mapped to the key.
    9292     */
    93     public LinkedHashSet<B> getValues(A key) {
     93    public Set<B> getValues(A key) {
    9494        if (!map.containsKey(key))
    95             return new LinkedHashSet<B>();
     95            return new TreeSet<B>();
    9696        return map.get(key);
    9797    }
     
    121121    }
    122122
    123     public Set<Entry<A, LinkedHashSet<B>>> entrySet() {
     123    public Set<Entry<A, Set<B>>> entrySet() {
    124124        return map.entrySet();
    125125    }
     
    135135     * Returns a collection of all value sets.
    136136     */
    137     public Collection<LinkedHashSet<B>> values() {
     137    public Collection<Set<B>> values() {
    138138        return map.values();
    139139    }
     
    155155     * Removes all mappings for a certain key.
    156156     */
    157     public LinkedHashSet<B> remove(A key) {
     157    public Set<B> remove(A key) {
    158158        return map.remove(key);
    159159    }
    160160
     161    @Override
    161162    public String toString() {
    162163        List<String> entries = new ArrayList<String>(map.size());
Note: See TracChangeset for help on using the changeset viewer.