Return a List of the second items from a list of pairs
@param list list
@param <T> first type
@param <W> second type
@return list of seconds
181888
public static <T,W> List<W> listSecond(List<Pair<T, W>> list) {
        ArrayList<W> ts = new ArrayList<W>();
        for (Pair<T, W> twPair : list) {
            ts.add(twPair.getSecond());
        }
        return ts;
    }
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;
	}
1263591
public static String[] difference(final String[] list1, final String[] list2) {
        HashSet<String> set = new HashSet<String>();
        HashSet<String> set1 = new HashSet<String>(Arrays.asList(list1));
        HashSet<String> set2 = new HashSet<String>(Arrays.asList(list2));
        for (final String s : list1) {
            if (!set2.contains(s)) {
                set.add(s);
            }
        }
        for (final String s : list2) {
            if (!set1.contains(s)) {
                set.add(s);
            }
        }
        return set.toArray(new String[set.size()]);
    }
1214956
public <T> List<T> subList(List<T> list) {
        if (!list.isEmpty()) {
            int from = offset != null ? toInt(offset) : 0;
            int to = limit != null ? (from + toInt(limit)) : list.size();
            return list.subList(from, Math.min(to,list.size()));
        } else {
            return list;
        }
    }
245905
protected <T> List<T> toArrayList(List<T> list) {
        if (list == null) {
            return null;
        }
        if (!list.getClass().equals(ArrayList.class)) {
            list = new ArrayList<>(list);
        }
        return list;
    }
351917
private static <T> List<T> join(List<T> list1, List<T> list2) {
        return list1.appendList(list2);
    }
1065059
public static <T> List<T> disjoint(final List<? extends T> list1, final List<? extends T> list2) {
		List<T> intersection = intersection(list1, list2);
		List<T> towIntersection = union(intersection, intersection);
		return difference(union(list1, list2), towIntersection);
	}
817298
public static final <S, E> Functional<S> functionalList(List<E> list) {
		return new FunctionalList<S, E>(list); 
	}
64046
public static <T> List<T> slice(List<T> list, Integer start, Integer stop) {
        int size = list.size();

        if (start == null) {
            start = 0;
        } else if (start < 0) {
            start = size + start;
        }

        if (stop == null) {
            stop = size;
        } else if (stop < 0) {
            stop = size + stop;
        }

        if (start >= size || stop <= 0 || start >= stop) {
            return Collections.emptyList();
        }

        start = Math.max(0, start);
        stop = Math.min(size, stop);

        return list.subList(start, stop);
    }
101240
public static Object repeat(List<Object> list, int times) {
        if ( times < 1 )
            if (list instanceof Queue)
                return new LinkedList<>();
            else
                return new ArrayList<>(0);
        List<Object> lst = list instanceof Queue
                            ? new LinkedList<>(list)
                            : new ArrayList<>(list);
        if ( times == 1 )
            return lst;
        while ( times-- > 1 )
            lst.addAll(list);
        return lst;
    }
1156887
public static <E> E last(final List<E> list) {
        return list.get(list.size() - 1);
    }
167751
public List< T> getAllByHql(String secondHalfOfHql, Object paramValue1, Type paramType1, Object paramValue2, Type paramType2) {
        return getAllByHql(secondHalfOfHql, new Object[] {paramValue1, paramValue2}, new Type[]{paramType2, paramType2}, null, null);
    }
1006869
private static <T> T firstOf(final List<T> list) {
        return list.isEmpty()? null: list.get(0);
    }
528318
public static <T> List<T> sort(List<T> list, Comparator<? super T> comparator) {
        Collections.sort(list, comparator);
        return list;
    }
43484
public static <T> boolean compareLists(List<T> list1, List<T> list2) {
        if (list1 == list2)
            return true;
        if (list1 == null || list2 == null)
            return false;
        if (list1.size() != list2.size())
            return false;

        for (int i = 0; i < list1.size(); i++) {
            if (!list1.get(i).equals(list2.get(i))) {
                return false;
            }
        }
        return true;
    }
192749
public static <T> Collection<T> intersect(Collection<T> first,
                                              Collection<T> second) {
        E.checkNotNull(first, "first");
        E.checkNotNull(second, "second");

        HashSet<T> results = null;
        if (first instanceof HashSet) {
            @SuppressWarnings("unchecked")
            HashSet<T> clone = (HashSet<T>) ((HashSet<T>) first).clone();
            results = clone;
        } else {
            results = new HashSet<>(first);
        }
        results.retainAll(second);
        return results;
    }
925572
public static <T> T firstValue(List<T> list) {
        if (list != null && !list.isEmpty()) {
            return list.get(0);
        }
        return null;
    }