Java SortedSet addMapEntry(Map> map, T1 keyEntry, T2 setEntry)

Here you can find the source of addMapEntry(Map> map, T1 keyEntry, T2 setEntry)

Description

add Map Entry

License

Open Source License

Declaration

public static <T1, T2> void addMapEntry(Map<T1, SortedSet<T2>> map,
            T1 keyEntry, T2 setEntry) 

Method Source Code

//package com.java2s;
/**// w  ww. j a v a  2s  .  c om
 * Copyright (C) 2007-2011, Jens Lehmann
 *
 * This file is part of DL-Learner.
 *
 * DL-Learner is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * DL-Learner is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Map;

import java.util.SortedSet;

import java.util.TreeSet;

public class Main {
    public static <T1, T2> void addMapEntry(Map<T1, SortedSet<T2>> map,
            T1 keyEntry, T2 setEntry) {
        if (map.containsKey(keyEntry)) {
            map.get(keyEntry).add(setEntry);
        } else {
            SortedSet<T2> newSet = new TreeSet<T2>();
            newSet.add(setEntry);
            map.put(keyEntry, newSet);
        }
    }
}

Related

  1. arrayToSortedStringSet(Collection strings)
  2. asSortedSet(T... args)
  3. asSortedSet(T... elements)
  4. computeGraphCauselessFromGraphLmms( List>>> causesByDepByNameList)