Java SortedSet getSortedIntersectionValues(Collection colection1, Collection colection2)

Here you can find the source of getSortedIntersectionValues(Collection colection1, Collection colection2)

Description

get Sorted Intersection Values

License

LGPL

Declaration

public static <T> Set<T> getSortedIntersectionValues(Collection<T> colection1, Collection<T> colection2) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

import java.util.Collection;

import java.util.HashSet;

import java.util.Set;
import java.util.TreeSet;

public class Main {
    public static <T> Set<T> getSortedIntersectionValues(Collection<T> colection1, Collection<T> colection2) {
        Set<T> set = new TreeSet<>();
        set.addAll(getIntersectionValues(colection1, colection2));
        return set;
    }/*from  www  . j av a2  s  . co  m*/

    public static <T> Set<T> getIntersectionValues(Collection<? extends T> colection1,
            Collection<? extends T> colection2) {

        Set<T> ret = new HashSet<T>();
        if (colection1 == null || colection2 == null)
            return ret;

        for (T value : colection1) {
            if (colection2.contains(value))
                ret.add(value);
        }
        return ret;
    }
}

Related

  1. doubleForDescreteStartAndEnds(SortedSet hours)
  2. entriesSortedByValues( Map map)
  3. fillOutHourly(SortedSet hours)
  4. getEntryOrEmptySet(K key, Map> map)
  5. getFlatItems(Map> linkedWorkItemIDsMap)
  6. getSortedTypes(Class[] types)
  7. intersect(SortedSet pSet1, SortedSet pSet2)
  8. intersectSorted(final Collection c1, final Collection c2)
  9. mapToSortedSet(Map map)