Code example for SortedMap

Methods: get, put

0
            throw new NullPointerException();
        } 
        if (value == null) {
            return; 
        } 
        LinkedList<String> list = keyTable.get(key);
        if (list == null) {
            list = new LinkedList<String>();
            keyTable.put(key, list);
        } 
        list.add(value);
        props.add(key);
        props.add(value);
    } 
 
    public void removeAll(String key) {
        keyTable.remove(key);
 
        for (int i = 0; i < props.size(); i += 2) {
            if (key.equals(props.get(i))) {
                props.remove(i); // key
                props.remove(i); // value
            } 
        } 
    } 
 
    public void addAll(String key, List<String> headers) {
        for (String header : headers) {
            add(key, header);
        } 
    } 
 
    public void addIfAbsent(String key, String value) {
        if (get(key) == null) {
            add(key, value);
        } 
    } 
 
    public void set(String key, String value) {
        removeAll(key);
        add(key, value);
    } 
 
    public Map<String, List<String>> getFieldMap() {
        Map<String, List<String>> result = new TreeMap<String, List<String>>(
                String.CASE_INSENSITIVE_ORDER); // android-changed
        for (Map.Entry<String, LinkedList<String>> next : keyTable
                .entrySet()) {
            List<String> v = next.getValue();
            result.put(next.getKey(), Collections.unmodifiableList(v));
        } 
        return Collections.unmodifiableMap(result);
    } 
 
    public String get(int pos) {
        if (pos >= 0 && pos < props.size() / 2) {
            return props.get(pos * 2 + 1);
        } 
        return null; 
    } 
 
    public String getKey(int pos) {
        if (pos >= 0 && pos < props.size() / 2) {
            return props.get(pos * 2);
        } 
        return null; 
    } 
 
    public String get(String key) {
        LinkedList<String> result = keyTable.get(key);
        if (result == null) {
            return null; 
        } 
        return result.getLast();
    }