Java集合之AbstractSequentialList
来源:互联网 发布:星星知我心1983百度云 编辑:程序博客网 时间:2024/06/03 21:06
public abstract class AbstractSequentialList<E> extends AbstractList<E> {//继承AbstractList JDK1.7 java.util protected AbstractSequentialList() {//构造器protected } public E get(int index) {//返回此列表中指定位置上的元素 try { return listIterator(index).next();//直接从此处开始迭代然后获取返回 } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } } 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); } } public void add(int index, E element) {//在此列表中的指定位置上插入指定的元素 try { listIterator(index).add(element);//直接迭代插入元素 } catch (NoSuchElementException exc) { throw new IndexOutOfBoundsException("Index: "+index); } } 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); } } public boolean addAll(int index, Collection<? extends E> c) {//在此列表中指定的位置上插入指定 collection 中的所有元素 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(); } public abstract ListIterator<E> listIterator(int index);//双向迭代器}
0 0
- Java集合之AbstractSequentialList
- Java常见集合框架(四):List之AbstractSequentialList、LinkedList
- java集合分析(8):AbstractSequentialList
- 解析java.util集合类源码(AbstractSequentialList)
- Java 集合深入理解(8):AbstractSequentialList
- Java 集合深入理解(8):AbstractSequentialList
- Java 集合深入理解(8):AbstractSequentialList
- 源码分析-java-AbstractSequentialList
- java.util.AbstractSequentialList<E>
- AbstractSequentialList
- AbstractSequentialList
- 5-3、java.util.AbstractSequentialList
- java.util.AbstractSequentialList学习笔记
- JDK源码阅读之List和AbstractSequentialList
- 共同学习Java源代码--数据结构--AbstractSequentialList类
- AbstractSequentialList说明
- Java集合之Set集合
- java集合之集合简介
- mac 终端 常用命令
- cpp的处理流
- ORA-01653: 表 USR_GD.T_PREDICT_SCORE_RESULT_FDY 无法通过 128 (在表空间 USERS 中) 扩展
- IntelliJ idea创建Spring MVC的Maven项目
- web项目与非web项目的区别
- Java集合之AbstractSequentialList
- js中flexible.js实现淘宝弹性布局方案
- Java类加载双亲委派机制的一点思考
- Codeforces Round #378 (Div. 2) && codeforces 733D(思维枚举)
- 安装mysql完整流程
- 爬虫笔记
- 第九周OJ第几天
- Wireshark过滤语法
- 水波纹动画和飘雪动画