Java List Value Add add(final Integer id, final TreeMap> map, T object)

Here you can find the source of add(final Integer id, final TreeMap> map, T object)

Description

add

License

MIT License

Parameter

Parameter Description
id a parameter
map a parameter
object a parameter

Declaration

static <T> void add(final Integer id, final TreeMap<Integer, List<T>> map, T object) 

Method Source Code

//package com.java2s;
/*//from w w  w  . j av  a 2s .  c o  m
 * libChEBIj (c) University of Manchester 2015
 *
 * libChEBIj is licensed under the MIT License.
 * 
 * To view a copy of this license, visit <http://opensource.org/licenses/MIT/>.
 */

import java.util.*;

public class Main {
    /**
     * 
     * @param id
     * @param map
     * @param object
     */
    static <T> void add(final Integer id, final TreeMap<Integer, List<T>> map, T object) {
        List<T> list = map.get(id);

        if (list == null) {
            list = new ArrayList<>();
            map.put(id, list);
        }

        list.add(object);
    }
}

Related

  1. add(final List list, final T... objects)
  2. add(final List toList, final List fromList)
  3. add(List list, int index, Object element)
  4. add(List valList, Object src)