linkedList 详解

来源:互联网 发布:水滴破解软件下载 编辑:程序博客网 时间:2024/05/21 17:19
linkedList  详解


1.定义了两个transient 变量 Entry<E> header 和int size =0


2.构造函数LinkedList() 生一个空的链表
  构造函数LinkedList(Collection col)


3. public E getFirst() 返回list第一个元素值


4. public E getLast() 返回List最后一个元素值


5. public E removeFirst() 移除LIst第一个元素  返回移除元素的值


6. public E removeLast() 移除LIst最后一个元素  返回移除元素的值


7 . public void addFirst(E e) 在list的第一个元素前加入一个元素


8. public void addLast(E e) 在List末尾加一个元素


9  public boolean contains(Object o) 根据元素索引值得查询 判断元素是否存在


10  public int size() 返回list的大小


11.public boolean add(E e)在list的末尾添加元素  与方法addLast(E e)一致 只是返回不同而已


12 public boolean remove(Object o) 删除某一个元素  只是删除第一个匹配的值


13 public boolean addAll(Collection<? extends E> c) list末尾添加集合中所有元素


13 public boolean addAll(Collection<? extends E> c) list指定位置添加集合中所有元素


14  public void clear() 移除所有元素


15 public E get(int index) 获取list指定位置的元素值


16 public E set(int index, E element) 给指定位置元素赋值


17  public void add(int index, E element)  指定位置插入新元素


18  public E remove(int index) 移除指定位置的元素


19   private Entry<E> entry(int index)  根据索引找到对应元素


20 public int indexOf(Object o)  Returns the index of the first occurrence of the specified element


21 public int lastIndexOf(Object o)  Returns the index of the last occurrence of the specified element 从链表尾部开始收索  返回第一个匹配的值


22   public E peek() 队列的操作 返回第一个元素


23  public E element() 返回第一个元素


24  public E poll()  移除第一个一个元素 返回第一个元素值


25  public E remove() 移除第一个一个元素 返回第一个元素值


26  public boolean offer(E e) 队列的操作 List末尾添加元素


27 public boolean offerFirst(E e) List头添加元素


28   public boolean offerLast(E e)  List头添加元素


29  public E peekFirst()  返回头部元素


30 public E peekLast() 返回尾部元素


31  public E pollFirst() 移除LIst第一个元素  返回移除元素的值


32  public E pollLast()  移除LIst最后一个元素  返回移除元素的值


33 public void push(E e) List头添加元素


34  public E pop()  移除LIst第一个元素  返回移除元素的值


35  public boolean removeFirstOccurrence(Object o) 移除第一个匹配值


36 public boolean removeLastOccurrence(Object o) 移除最后一个匹配值


37  public ListIterator<E> listIterator(int index) 迭代器


   a. public boolean hasNext() 是否有下一个
   b. public E next()  下一个元素值
   c.public E previous() 前一个元素值
    d.public int nextIndex() 下一个值得索引
  e.public int previousIndex() 前一个值得索引
0 0
原创粉丝点击