AbstractSequentialList抽象类源码解析
来源:互联网 发布:linux 批量删除文件夹 编辑:程序博客网 时间:2024/06/01 20:49
所在包
package java.util;
继承AbstractList抽象类
public abstract class AbstractSequentialList<E> extends AbstractList<E> {// 内部代码下面讲解}
空构造器
protected AbstractSequentialList() { }
获取指定index位置的元素
这里是通过迭代器获取
/* @throws IndexOutOfBoundsException {@inheritDoc} */ public E get(int index) { try { return listIterator(index).next(); } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
更新index位置元素
通过迭代器更新
/* @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} * @throws IndexOutOfBoundsException {@inheritDoc} */ public E set(int index, E element) { try { ListIterator<E> e = listIterator(index); E oldVal = e.next(); e.set(element); return oldVal; } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
index位置插入元素
/* @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} * @throws IndexOutOfBoundsException {@inheritDoc} */ public void add(int index, E element) { try { listIterator(index).add(element); } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
删除元素 o
/* @throws UnsupportedOperationException {@inheritDoc} * @throws IndexOutOfBoundsException {@inheritDoc} */ public E remove(int index) { try { ListIterator<E> e = listIterator(index); E outCast = e.next(); e.remove(); return outCast; } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
index开始插入集合c中的元素
/* @throws UnsupportedOperationException {@inheritDoc} * @throws ClassCastException {@inheritDoc} * @throws NullPointerException {@inheritDoc} * @throws IllegalArgumentException {@inheritDoc} * @throws IndexOutOfBoundsException {@inheritDoc} */ public boolean addAll(int index, Collection<? extends E> c) { try { boolean modified = false; ListIterator<E> e1 = listIterator(index); Iterator<? extends E> e2 = c.iterator(); while (e2.hasNext()) { e1.add(e2.next()); modified = true; } return modified; } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } }
获取迭代器
public Iterator<E> iterator() { return listIterator(); }
迭代器抽象方法
/* @throws IndexOutOfBoundsException {@inheritDoc} */ public abstract ListIterator<E> listIterator(int index);
0 0
- AbstractSequentialList抽象类源码解析
- 解析java.util集合类源码(AbstractSequentialList)
- AbstractSequentialList源码分析
- 源码分析-java-AbstractSequentialList
- AbstractCollection抽象类源码解析
- AbstractList抽象类源码解析
- AbstractQueue抽象类源码解析
- AbstractSet抽象类源码解析
- EnumSet抽象类源码解析
- Dictionary抽象类源码解析
- AbstractMap抽象类源码解析
- AbstractSequentialList
- AbstractSequentialList
- JDK源码阅读之List和AbstractSequentialList
- 共同学习Java源代码--数据结构--AbstractSequentialList类
- 抽象类错误解析
- AbstractSequentialList说明
- 消息接收解析抽象类
- JSP
- rabbitMQ guest账号登录总是提示失败
- Fragment有参构造提示Avoid non-default constructors in fragments: 解决方案
- Virtex-6 Clock 资源
- JavaBean及其使用
- AbstractSequentialList抽象类源码解析
- SI与EMI(一)
- HDU5676(DFS打表+二分查找)
- POJ 3070 Fibonacci(简单矩阵快速幂)
- python列表VS字典
- 在JSP中使用JavaBean
- Android中使用Stack对Activity的管理
- 手持两把锟斤拷,口中疾呼烫烫烫。脚踏千朵屯屯屯,笑看万物锘锘锘
- M3&STM32零散知识学习