Java SortedSet intersectSorted(final Collection c1, final Collection c2)

Here you can find the source of intersectSorted(final Collection c1, final Collection c2)

Description

intersect Sorted

License

Open Source License

Declaration

public static <T extends Comparable<T>> SortedSet<T> intersectSorted(final Collection<? extends T> c1,
            final Collection<? extends T> c2) 

Method Source Code

//package com.java2s;
/* *********************************************************************** *
 * project: org.matsim.*//from w  ww.  jav  a2  s .c  o  m
 * CollectionUtils.java
 *                                                                         *
 * *********************************************************************** *
 *                                                                         *
 * copyright       : (C) 2013 by the members listed in the COPYING,        *
 *                   LICENSE and WARRANTY file.                            *
 * email           : info at matsim dot org                                *
 *                                                                         *
 * *********************************************************************** *
 *                                                                         *
 *   This program 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 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *   See also COPYING, LICENSE and WARRANTY file                           *
 *                                                                         *
 * *********************************************************************** */

import java.util.Collection;

import java.util.SortedSet;
import java.util.TreeSet;

public class Main {
    public static <T extends Comparable<T>> SortedSet<T> intersectSorted(final Collection<? extends T> c1,
            final Collection<? extends T> c2) {
        final SortedSet<T> set = new TreeSet<T>();
        for (T t : c1) {
            if (c2.contains(t))
                set.add(t);
        }
        return set;
    }
}

Related

  1. getEntryOrEmptySet(K key, Map> map)
  2. getFlatItems(Map> linkedWorkItemIDsMap)
  3. getSortedIntersectionValues(Collection colection1, Collection colection2)
  4. getSortedTypes(Class[] types)
  5. intersect(SortedSet pSet1, SortedSet pSet2)
  6. mapToSortedSet(Map map)
  7. newSortedSet()
  8. setDistance(SortedSet s1, SortedSet s2)
  9. setminus(SortedSet pSet1, SortedSet pSet2)