Ignore:
Timestamp:
06.02.2010 17:37:52 (2 years ago)
Author:
bastiK
Message:

autocompletion: Always add the preset keys/values to the autocompletion list.
Does not apply to the Properties dialog, because it has a seperate implementation of the autocompletion feature.

File:
1 edited

Legend:

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

    r2702 r2946  
    22package org.openstreetmap.josm.tools; 
    33 
    4 import java.util.ArrayList; 
     4import java.util.LinkedHashSet; 
    55import java.util.List; 
    66import java.util.HashMap; 
    77 
    88/** 
    9  * Maps keys to a list of values. Partial implementation. Extend if you need more! 
     9 * Maps keys to ordered sets of values. 
    1010 */ 
    11 public class MultiMap<A, B> extends HashMap<A, List<B>> { 
    12     public void add(A key, B value) { 
    13         List<B> vals = get(key); 
     11public class MultiMap<A, B> extends HashMap<A, LinkedHashSet<B>> { 
     12    /** 
     13     * Map a key to a value. Can be called multiple times with the same key, but different value. 
     14     */ 
     15    public void put(A key, B value) { 
     16        LinkedHashSet<B> vals = get(key); 
    1417        if (vals == null) { 
    15             vals = new ArrayList<B>(); 
     18            vals = new LinkedHashSet<B>(); 
    1619            put(key, vals); 
    1720        } 
    1821        vals.add(value); 
    1922    } 
     23     
     24    /** 
     25     * Put a key that maps to nothing. 
     26     */ 
     27    public void putVoid(A key) { 
     28        if (containsKey(key)) 
     29            return; 
     30        put(key, new LinkedHashSet<B>()); 
     31    } 
     32 
     33    /** 
     34     * Returns a list of values for the given key 
     35     * or an empty list, if it maps to nothing. 
     36     */ 
     37    public LinkedHashSet<B> getValues(A key) { 
     38        if (!containsKey(key)) 
     39            return new LinkedHashSet<B>(); 
     40        return get(key); 
     41    } 
    2042} 
Note: See TracChangeset for help on using the changeset viewer.