all objects in list1 that are not in list2

@param <T>
@param list1
First collection
@param list2
Second collection
@return The collection difference list1 - list2
969362
public static <T> Collection<T> diff(Collection<T> list1, Collection<T> list2) {
    Collection<T> diff = new ArrayList<T>();
    for (T t : list1) {
      if (!list2.contains(t)) {
        diff.add(t);
      }
    }
    return diff;
  }
36761
public synchronized List<PType> narrowest(List<PType> t1, List<PType> t2)
	{
		return allSubTypes(t1, t2, false) == Result.Yes ? t1 : t2;
	}
528318
public static <T> List<T> sort(List<T> list, Comparator<? super T> comparator) {
        Collections.sort(list, comparator);
        return list;
    }
1347277
public static <E> Set<E> diff(Set<E> s1, Set<E> s2) {
    Set<E> s = new HashSet<E>();
    for (E o : s1) {
      if (!s2.contains(o)) {
        s.add(o);
      }
    }
    return s;
  }
318430
public static double computeCorrelation(final List<Double> list1, final List<Double> list2)
    {
        final SpearmansRankCorrelation_old src = new SpearmansRankCorrelation_old();
        for (int i = 0; i < list1.size(); i++) {
            src.addXValue(Integer.toString(i), list1.get(i));
            src.addYValue(Integer.toString(i), list2.get(i));
            i++;
        }
        return src.calculate();
    }
578716
public static <T> List<T> intersection(final List<? extends T> list1, final List<? extends T> list2) {
		List<? extends T> smaller = list1;
		List<? extends T> larger = list2;
		if (list1.size() > list2.size()) {
			smaller = list2;
			larger = list1;
		}

		// 克隆一个可修改的副本
		List<T> newSmaller = new ArrayList<T>(smaller);
		List<T> result = new ArrayList<T>(smaller.size());
		for (final T e : larger) {
			if (newSmaller.contains(e)) {
				result.add(e);
				newSmaller.remove(e);
			}
		}
		return result;
	}
230947
@SuppressWarnings("unchecked")
	public static <T> List<T> aggregateToList(Object v1, T v2) {
		List<Object> aggregatedValues = toList(v1);
		aggregatedValues.add(v2);
		return (List<T>) aggregatedValues;
	}
627115
public static <E> Collection<E> difference(Set<E> first, Set<E> second, Function<E, Integer> hasher) {
        if (first == null || first.size() == 0) {
            return Collections.emptyList();
        }

        if (second == null || second.size() == 0) {
            return first;
        }

        Map<Integer, E> map = new HashMap();

        first.stream().forEach(e -> map.put(hasher.apply(e), e));
        second.stream().forEach(e -> map.remove(hasher.apply(e)));

        return Collections.unmodifiableCollection(map.values());
    }
519540
public static <T> Set<T> union(final Collection<? extends T>... lists)
	{
		Set<T> s = new HashSet<T>();

		for (Collection<? extends T> list : lists)
			if (list != null)
				s.addAll(list);

		return s;
	}
920230
private static <T> List<T> intersect(T[] first, T[] second) {
    List<T> result = new ArrayList<>();
    for (T a : first) {
      for (T b : second) {
        if (a.equals(b)) {
          result.add(b);
          break;
        }
      }
    }
    return result;
  }
10199
public static <T extends Comparable<? super T>> List<T> sort(final List<T> list) {
        Validate.notNull(list, "Cannot execute list sort: list is null");
        final Object[] a = list.toArray();
        Arrays.sort(a);
        
        return fillNewList(a, list.getClass());
    }
1323177
public static <E> List<E> buildMergedList(
            Collection<E> collection1, Collection<E> collection2) {
        List<E> mergedList = new ArrayList<>(collection1);
        mergedList.addAll(collection2);
        return mergedList;
    }
351917
private static <T> List<T> join(List<T> list1, List<T> list2) {
        return list1.appendList(list2);
    }
209165
@CheckReturnValue
	@VisibleForTesting
	ImmutableList<Server> mergeServerLists(List<Server> firstList, List<Server> secondList) {
		ImmutableList.Builder<Server> results = ImmutableList.builder();
		List<Server> toProcess = new ArrayList<>(secondList);
		for (Server firstServer : firstList) {
			if (toProcess.contains(firstServer)) {
				Server found = toProcess.get(secondList.indexOf(firstServer));
				results.add(merge(firstServer, found));
				// remove server as it is already merged
				toProcess.remove(found);
			} else {
				results.add(firstServer);
			}
		}
		// add servers from the second list that are not in the first one
		results.addAll(toProcess);
		return results.build();
	}
1229468
public static <T1, T2> List<Tuple2<T1, T2>> zip(Collection<T1> col1, Collection<T2> col2) {
        int resultSize = _max(col1.size(), col2.size());
        List<Tuple2<T1, T2>> result = new ArrayList<Tuple2<T1, T2>>(resultSize);

        Iterator<T1> it1 = col1.iterator();
        Iterator<T2> it2 = col2.iterator();

        while (resultSize-- > 0) {
            result.add(tuple(next(it1), next(it2)));
        }

        return result;
    }
604550
public static <T> List<T> sort(List<T> list, Comparator<? super T> c) {
		Collections.sort(list, c);
		return list;
	}
226232
public static <T> List<T> sub(List<T> list, int start, int end) {
		return sub(list, start, end, 1);
	}