Skip to content

Commit 28c8891

Browse files
committed
update List
1 parent 086eafc commit 28c8891

File tree

3 files changed

+54
-48
lines changed

3 files changed

+54
-48
lines changed

group20/592146505/data _structure/src/cn/wsc/util/ArrayList.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.util.Arrays;
44
import java.util.ConcurrentModificationException;
5-
import java.util.Iterator;
65
import java.util.NoSuchElementException;
76

87
/**
@@ -45,11 +44,11 @@ public boolean isEmpty() {
4544
return size == 0;
4645
}
4746

48-
// @Override
49-
// public boolean contains(Object o) {
50-
// // TODO Auto-generated method stub
51-
// return false;
52-
// }
47+
// @Override
48+
// public boolean contains(Object o) {
49+
// // TODO Auto-generated method stub
50+
// return false;
51+
// }
5352

5453
@Override
5554
public Iterator<E> iterator() {
@@ -78,6 +77,7 @@ public E next() {
7877
return (E) elementData[lastRet = cursor++];
7978
}
8079

80+
@Override
8181
public void remove() {
8282
if (lastRet < 0)
8383
throw new IllegalStateException();

group20/592146505/data _structure/src/cn/wsc/util/LinkedList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package cn.wsc.util;
22

33
import java.util.ConcurrentModificationException;
4-
import java.util.Iterator;
54
import java.util.NoSuchElementException;
65

76
/**
@@ -63,6 +62,7 @@ public E next() {
6362
return get(lastRet = cursor++);
6463
}
6564

65+
@Override
6666
public void remove() {
6767
if (lastRet < 0)
6868
throw new IllegalStateException();
@@ -211,7 +211,7 @@ public E getLast() {
211211
@Override
212212
public E set(int index, E e) {
213213
checkElementIndex(index);// 索引范围检查
214-
//获取索引处节点,填入新值,返回原值
214+
// 获取索引处节点,填入新值,返回原值
215215
Node<E> x = node(index);
216216
E oldVal = x.item;
217217
x.item = e;
Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package cn.wsc.util;
22

3-
import java.util.Iterator;
4-
53
/**
64
* List接口
75
*
@@ -12,88 +10,96 @@
1210
* @param <T>
1311
*/
1412
public interface List<E> {
15-
13+
1614
/**
1715
* 获取集合元素个数
16+
*
1817
* @return
1918
*/
2019
int size();
21-
20+
2221
/**
2322
* 集合是否为空
23+
*
2424
* @return
2525
*/
2626
boolean isEmpty();
27-
28-
// /**
29-
// * 是否包含指定元素
30-
// * @param o
31-
// * @return
32-
// */
33-
// boolean contains(Object o);
34-
27+
28+
// /**
29+
// * 是否包含指定元素
30+
// * @param o
31+
// * @return
32+
// */
33+
// boolean contains(Object o);
34+
3535
/**
3636
* 获取当前集合迭代器对象
37+
*
3738
* @return
3839
*/
3940
Iterator<E> iterator();
40-
//
41-
// /**
42-
// * 返回集合数组对象
43-
// *
44-
// * @return
45-
// */
46-
// Object[] toArray();
47-
//
48-
// /**
49-
// * 将集合元素复制到新数组中
50-
// * @param a
51-
// * @return
52-
// */
53-
// <T> T[] toArray(T[] a);
54-
41+
//
42+
// /**
43+
// * 返回集合数组对象
44+
// *
45+
// * @return
46+
// */
47+
// Object[] toArray();
48+
//
49+
// /**
50+
// * 将集合元素复制到新数组中
51+
// * @param a
52+
// * @return
53+
// */
54+
// <T> T[] toArray(T[] a);
55+
5556
/**
5657
* 在集合末尾追加元素
58+
*
5759
* @param e
5860
* @return
5961
*/
6062
boolean add(E e);
61-
63+
6264
/**
6365
* 将元素添加至指定指定索引处
66+
*
6467
* @param index
6568
* @param e
6669
* @return
6770
*/
68-
boolean add(int index,E e);
69-
71+
boolean add(int index, E e);
72+
7073
/**
7174
* 获取指定索引处元素
75+
*
7276
* @param index
7377
* @return
7478
*/
7579
E get(int index);
76-
80+
7781
/**
7882
* 替换指定索引处元素为新元素,并返回被替换元素,
83+
*
7984
* @param index
8085
* @param e
8186
* @return
8287
*/
8388
E set(int index, E e);
84-
89+
8590
/**
8691
* 删除并返回指定指定索引处元素
92+
*
8793
* @param index
8894
* @return
8995
*/
9096
E remove(int index);
91-
92-
// /**
93-
// * 返回该对象在集合中的下标,不存在返回-1
94-
// * @param o
95-
// * @return
96-
// */
97-
// int indexOf(Object o);
98-
97+
98+
// /**
99+
// * 返回该对象在集合中的下标,不存在返回-1
100+
// * @param o
101+
// * @return
102+
// */
103+
// int indexOf(Object o);
104+
99105
}

0 commit comments

Comments
 (0)