Collection<E> //Collection内建函数更接近Set因为需要照顾Set,Set没有的高级功能
boolean add(Object element) //addAll
boolean remove(Object element) //removeAll 删除指定位置的元素需要迭代器
void clear()
int size()
boolean isEmpty()
boolean contains(Object element) comtainsAll(Collection<?> other)
Object[] toArray()
Iterator<E> iterator()
boolean hasNext()
E next()
void remove() //无void add()
List<E>
void add(int i, E element) //addAll
E remove(int i)
E get(int i)
E set(int i, E element)
int indexOf(Object element)
int lastIndexOf(Object element)
ListIterator<E> listIterator() //继承自Iterator,有序集合才能在指定位置add
void add(E newElement)
void set(E newElement)
int nextIndex()
Set<E>
//基本同Collection
SortedSet<E>
E fisrt()
E last()
Queue<E>
boolean add(E element) //尾部增加
boolean offer(E element) //满了不会抛出IllegalStateException,而是返回false
E remove() //头部删除
E poll() //空了不会抛出NoSuchElementException,而是返回null
E element() //头部读取
E peek() //空了不会抛出NoSuchElementException,而是返回null
Deque<E>
void addFirst(E element)
void addLast(E element)
boolean offerFirst(E element)
boolean offerLast(E element)
E removeFirst()
E removeLast()
E pollFirst()
E pollLast()
E getFirst()
E getLast()
E peekFirst()
E peekLast()
实现分析:
ArrayList最大功能是实现List,所以内建函数和List比较接近
LinkedList全能,所以为了实现最大功能,内建函数和Deque比较接近
ArrayDeque就是为了实现Deque,内建函数基本和Deque接近
HashSet内建函数基本和Set接近,而Set和Collection接近
TreeSet内建函数和SortedSet接近
PriorityQueue比较特殊,继承自Queue父接口,所以基本一样,add,remove,但效果完全不一样,所以定义的时候一般不使用接口定义