Skip to content

Commit d0b1226

Browse files
committed
update
1 parent a08c56e commit d0b1226

File tree

13 files changed

+22
-12
lines changed

13 files changed

+22
-12
lines changed

bin/.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
/kevinGates/
22
/kevinRedis/
33
/dataStructures/
4-
/kevinCollection/
5-
/generic/

bin/generic/AbstractBox.class

749 Bytes
Binary file not shown.

bin/generic/Box.class

1.99 KB
Binary file not shown.

bin/generic/List.class

316 Bytes
Binary file not shown.
1.31 KB
Binary file not shown.
1.73 KB
Binary file not shown.
1.2 KB
Binary file not shown.

bin/kevinCollection/ListExample.class

5.3 KB
Binary file not shown.
833 Bytes
Binary file not shown.

bin/kevinCollection/SetExample.class

1.8 KB
Binary file not shown.

bin/kevinCollection/SetExample1.class

1.8 KB
Binary file not shown.

src/dataStructures/ArrayListkevin.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import java.util.List;
55
import java.util.ListIterator;
66

7-
public class ArrayListkevin<T> implements CollectionKevin {
7+
public class ArrayListkevin<T> implements CollectionKevin<T> {
88

99
private static final int MINIMUM_SIZE = 1024;
1010

@@ -13,53 +13,60 @@ public class ArrayListkevin<T> implements CollectionKevin {
1313

1414
public void add(Object obj) {
1515
add(size, obj);
16-
}
16+
}
1717

1818
public void add(int index, Object obj) {
1919
array[index] = (T) obj;
2020
size ++;
2121
}
2222

23-
public boolean addAll(Collection<? extends E> c) {
23+
public boolean addAll(Collection<? extends T> c) {
2424
addAll(size, c);
2525
return false;
26-
}
26+
}
2727

28-
public boolean addAll(int index, Collection<? extends E> c) {
28+
public boolean addAll(int index, Collection<? extends T> c) {
2929
T[] merge = (T[]) new Object[array.length + 10];
3030
for(int i=0;i<array.length;i++) {
3131
merge[i] = array[i];
3232
}
3333

3434
// for(int i=0;i<c.length;i++) {
3535
// merge[i] = array[i];
36-
// }
36+
// }
3737
return false;
3838
}
3939

4040
public Object get(int index) {
4141
return array[index];
4242
}
43+
4344
public int indexOf(Object obj) {
4445
return 0;
4546
}
47+
4648
public int lastIndexOf(Object obj) {
4749
return 0;
4850
}
51+
4952
public ListIterator listIterator( ) {
5053
return null;
5154
}
55+
5256
public ListIterator listIterator(int index) {
5357
return null;
5458
}
59+
5560
public Object remove(int index) {
5661
array[index] = null;
5762
return array;
5863
}
64+
5965
public Object set(int index, Object obj) {
6066
array[index] = (T) obj;
6167
return array;
6268
}
69+
6370
public List subList(int start, int end) {
6471

6572
return null;

src/kevinCollection/ListExample.java

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ public class ListExample {
1515
public static void main(String[] args) {
1616
//ExampleThree();
1717
//iteratingOverAList();
18-
addAllExample();
18+
//addAllExample();
19+
iteratingOverAList();
1920
}
2021

2122
public static void ExampleOne() {
@@ -113,8 +114,6 @@ public static void iteratingOverAList() {
113114
listStrings.add("One");
114115
listStrings.add("Two");
115116
listStrings.add("Three");
116-
// But this will cause compile error
117-
//listStrings.add(123);
118117

119118
List<Number> linkedNumbers = new LinkedList<>();
120119
linkedNumbers.add(new Integer(123));
@@ -126,7 +125,13 @@ public static void iteratingOverAList() {
126125
while (iterator.hasNext()) {
127126
System.out.println(iterator.next());
128127
}
129-
128+
129+
System.out.println("list iterator Specified");
130+
Iterator<String> iteratorSpecified = listStrings.listIterator();
131+
while (iteratorSpecified.hasNext()) {
132+
System.out.println(iterator.next());
133+
}
134+
130135
// Iterator<Number> iterator = linkedNumbers.listIterator();
131136
// while (iterator.hasNext()) {
132137
// System.out.println(iterator.next());

0 commit comments

Comments
 (0)