Collection和Collections

Collection接口:

int size();
boolean isEmpty();
boolean contains();
Iterator<E> iterator();
Object[] toArray();
<T> T[] toArray(T[] a);
boolean add(E e);
boolean remove(Object o);
boolean containsAll(Collection<?> c);
boolean addAll(Colletion<? extends E> c);
boolean removeAll(Collection<?> c);
boolean removeIf(Predicate<? super E> filter);
boolean retainAll(Collection<?> c);
void clear();
boolean equals(Object o);
int hashCode();
default Spliterator<E> spliterator();
default Stream<E> stream();
default Stream<E> parallelStream();

Collections

public static <T extends Comparable<? super T>> void sort(List<T> list) ;
public static <T> void sort(List<T> list, Comparator<? super T> c) ;
public static <T> int binarySearch(List<? extends Comparable<? super T>> list, T key) ;
private static <T> int indexedBinarySearch(List<? extends Comparable<? super T>> list, T key);
private static <T> int iteratorBinarySearch(List<? extends Comparable<? super T>> list, T key);
private static <T> T get(ListIterator<? extends T> i, int index);
public static <T> int binarySearch(List<? extends T> list, T key, Comparator<? super T> c);
private static <T> int indexedBinarySearch(List<? extends T> l, T key, Comparator<? super T> c);
private static <T> int iteratorBinarySearch(List<? extends T> l, T key, Comparator<? super T> c);
public static void reverse(List<?> list);
public static void shuffle(List<?> list);
public static void shuffle(List<?> list, Random rnd);
public static void swap(List<?> list, int i, int j);
private static void swap(Object[] arr, int i, int j);
public static <T> void fill(List<? super T> list, T obj);
public static <T> void copy(List<? super T> dest, List<? extends T> src);
public static <T extends Object & Comparable<? super T>> T min(Collection<? extends T> coll);
public static <T> T min(Collection<? extends T> coll, Comparator<? super T> comp);
public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll);
public static <T> T max(Collection<? extends T> coll, Comparator<? super T> comp);
...

Collection是集合頂級接口。提供了對集合對象的基本操作的接口方法。Collections是一個工具類,包含各種有關集合的靜態多態方法,包括排序、搜索以及線程安全等各種操作,服務於Java的Collection框架。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章