// 排序 void sort(List<T> list); void sort(List<T> list, Comparator<? super T>); // 二分查找 int binarySearch(List list, T key); int binarySearch(List list, T key, Comparator<? super T> cmp); // 倒置 void reverse(List<?> list); // 打乱 void shuffle(List<?> list); // 交换 void swap(List list<?>, int i, int j); // 填充 void fill(List list<? super T>, T obj); // 复制 void copy(List<? super T> dest, List<? extends T> src); // 最值 T min(Collection<? extends T> coll); T min(Collection<? extends T> coll, Comparator<? super T> cmp); T max(Collection<? extends T> coll); T max(Collection<? extends T> coll, Comparator<? super T> cmp); // 旋转 void rotate(List list<?>, int distance); // 替换 boolean replaceAll(List<T> list, T oldVal, T newVal); // target列表在source列表中的位置 int indexSubList(List<?> source, List<?> target); int lastIndexSubList(List<?> source, List<?> target); XXX = {Collection, Set, SortedSet, List, Map, SortedMap}; // 返回一个内容不可更改的 XXX 容器 XXX unmodifiableXXX(XXX xxx); // 返回一个线程安全的 XXX 容器 XXX synchronizedXXX(XXX xxx); // 返回一个 XXX 容器,在编译期就进行类型检查 XXX checkedXXX(XXX<E> xxx, Class<E> class); // 返回空的YYY YYY={Iterator, ListIterator, Enumeration, Set, List, Map} YYY emptyYYY(); // 返回只有一个元素的容器 Set<T> singleton(T o); List<T> singletonList(T o); Map<K,V> singletonMap(K k,V v); List<T> nCopies(int n, T o); //返回一个有n个o对象的列表 Comparator<T> reverseOrder(); // 返回一个逆序比较器 Comparator<T> reverseOrder(Comparator<T> cmp) // 返回一个逆序比较器 Enumeration<T> enumeration(Collection<T> c); //集合转换为Enumeration ArrayList<T> list(Enumeration<T> e); // Enumeration转换为List int frequency(Collection<?> c, Object obj); //统计某个对象出现的次数 boolean disjoint(Collection c1, Collection c2); //如果两个集合中没有相同元素返回true boolean addAll(Collection<? super T>, T ...); //向集合中添加元素 Set<E> newSetFromMap(Map<E, Boolean> map); Queue<T> asLifoQueue(Deque<T> deque); //把Deque当作栈来用
本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。
我来说两句