Skip to content

Commit 8263c41

Browse files
committed
update
1 parent fbd232b commit 8263c41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+270
-5
lines changed

bin/.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
/kevinCollection/
2-
/kevinGates/
3-
/kevinRedis/
2+
/dataStructures/

bin/kevinGates/Animal.class

498 Bytes
Binary file not shown.
909 Bytes
Binary file not shown.
1.6 KB
Binary file not shown.

bin/kevinGates/Book.class

588 Bytes
Binary file not shown.

bin/kevinGates/CSVExample.class

1.68 KB
Binary file not shown.

bin/kevinGates/CalendarExample.class

1.68 KB
Binary file not shown.

bin/kevinGates/DataType.class

1.16 KB
Binary file not shown.

bin/kevinGates/Dog.class

498 Bytes
Binary file not shown.
1.66 KB
Binary file not shown.

bin/kevinGates/HashMapExample.class

2.21 KB
Binary file not shown.
2.68 KB
Binary file not shown.
1.16 KB
Binary file not shown.

bin/kevinGates/JframeExample.class

911 Bytes
Binary file not shown.

bin/kevinGates/KevinArrayList.class

930 Bytes
Binary file not shown.

bin/kevinGates/LanguageDetect.class

795 Bytes
Binary file not shown.

bin/kevinGates/ListExample.class

1.81 KB
Binary file not shown.

bin/kevinGates/ListExampleOne.class

1.35 KB
Binary file not shown.

bin/kevinGates/LongDemo.class

1.15 KB
Binary file not shown.

bin/kevinGates/Md5Example.class

1.63 KB
Binary file not shown.

bin/kevinGates/Overriding.class

915 Bytes
Binary file not shown.

bin/kevinGates/Person.class

902 Bytes
Binary file not shown.

bin/kevinGates/QueueExample.class

1.5 KB
Binary file not shown.

bin/kevinGates/RandomExample.class

895 Bytes
Binary file not shown.
834 Bytes
Binary file not shown.

bin/kevinGates/SettingsList.class

2.63 KB
Binary file not shown.

bin/kevinGates/StringExample.class

1.9 KB
Binary file not shown.

bin/kevinGates/UnixTimeExample.class

5.08 KB
Binary file not shown.

bin/kevinGates/User.class

941 Bytes
Binary file not shown.
1.22 KB
Binary file not shown.

bin/kevinGates/UserInterface.class

175 Bytes
Binary file not shown.
1.63 KB
Binary file not shown.
358 Bytes
Binary file not shown.
Binary file not shown.

bin/kevinGates/holdings.csv

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
id,Name
2+
1,Prashant Ghimire1
3+
1,Prashant Ghimire2
4+
1,Prashant Ghimire3
5+
1,Prashant Ghimire4
6+
1,Prashant Ghimire5
7+
1,Prashant Ghimire6
8+
1,Prashant Ghimire7
9+
1,Prashant Ghimire8
10+
1,Prashant Ghimire9
11+
1,Prashant Ghimire10
12+
1,Prashant Ghimire11
13+
1,Prashant Ghimire12
14+
1,Prashant Ghimire13
15+
1,Prashant Ghimire14
16+
1,Prashant Ghimire15
17+
1,Prashant Ghimire16
18+
1,Prashant Ghimire17
19+
1,Prashant Ghimire18
20+
1,Prashant Ghimire19
558 Bytes
Binary file not shown.
831 Bytes
Binary file not shown.
181 Bytes
Binary file not shown.

bin/kevinGates/jedis/redisJson.class

3.1 KB
Binary file not shown.
1.23 KB
Binary file not shown.
Binary file not shown.
916 Bytes
Binary file not shown.

bin/kevinGates/test.csv

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
id,Name
2+
1,Prashant Ghimire1
3+
1,Prashant Ghimire2
4+
1,Prashant Ghimire3
5+
1,Prashant Ghimire4
6+
1,Prashant Ghimire5
7+
1,Prashant Ghimire6
8+
1,Prashant Ghimire7
9+
1,Prashant Ghimire8
10+
1,Prashant Ghimire9
11+
1,Prashant Ghimire10
12+
1,Prashant Ghimire11
13+
1,Prashant Ghimire12
14+
1,Prashant Ghimire13
15+
1,Prashant Ghimire14
16+
1,Prashant Ghimire15
17+
1,Prashant Ghimire16
18+
1,Prashant Ghimire17
19+
1,Prashant Ghimire18
20+
1,Prashant Ghimire19
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package dataStructures;
2+
3+
import java.util.List;
4+
import java.util.ListIterator;
5+
6+
public class ArrayListkevin<T> implements CollectionKevin {
7+
8+
private static final int MINIMUM_SIZE = 1024;
9+
10+
private int size = 0;
11+
private T[] array = (T[]) new Object[MINIMUM_SIZE];
12+
13+
public void add(Object obj) {
14+
add(size, obj);
15+
}
16+
17+
public void add(int index, Object obj) {
18+
array[index] = (T) obj;
19+
size ++;
20+
}
21+
22+
public boolean addAll(int index, CollectionKevin c) {
23+
return false;
24+
}
25+
26+
public Object get(int index) {
27+
return array[index];
28+
}
29+
public int indexOf(Object obj) {
30+
return 0;
31+
}
32+
public int lastIndexOf(Object obj) {
33+
return 0;
34+
}
35+
public ListIterator listIterator( ) {
36+
return null;
37+
}
38+
public ListIterator listIterator(int index) {
39+
return null;
40+
}
41+
public Object remove(int index) {
42+
array[index] = null;
43+
return array;
44+
}
45+
public Object set(int index, Object obj) {
46+
array[index] = (T) obj;
47+
return array;
48+
}
49+
public List subList(int start, int end) {
50+
return null;
51+
}
52+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package dataStructures;
2+
3+
public class ArrayListkevinTest {
4+
5+
public static void main(String[] args) {
6+
ArrayListkevin<String> countries = new ArrayListkevin<String>();
7+
countries.add("canada");
8+
countries.add("United states");
9+
countries.add("United Kindom");
10+
11+
System.out.println("get:"+countries.get(2));
12+
13+
int[] cities= new int[1024];
14+
15+
for(int i=1;i<20;i++) {
16+
cities[i] = i;
17+
}
18+
19+
System.out.println("data:"+cities[2]);
20+
}
21+
22+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package dataStructures;
2+
3+
import java.util.List;
4+
import java.util.ListIterator;
5+
6+
public interface CollectionKevin<E> {
7+
void add(int index, Object obj);
8+
boolean addAll(int index, CollectionKevin c);
9+
Object get(int index);
10+
int indexOf(Object obj);
11+
int lastIndexOf(Object obj);
12+
ListIterator listIterator( );
13+
ListIterator listIterator(int index);
14+
Object remove(int index);
15+
Object set(int index, Object obj);
16+
List subList(int start, int end);
17+
}

src/dataStructures/Hashtable.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package dataStructures;
2+
3+
import java.util.*;
4+
public class Hashtable {
5+
6+
public static void main(String[] args) {
7+
// TODO Auto-generated method stub
8+
// Hashtable<Word, String> table = new Hashtable<>();
9+
//
10+
// Word word = new Word("cat");
11+
// table.put(word, "an animal");
12+
//
13+
// String definition = table.get(word);
14+
}
15+
16+
// public class Word {
17+
// private String name;
18+
//
19+
// public Word(String name) {
20+
// this.name = name;
21+
// }
22+
// }
23+
}

src/kevinCollection/ListExample.java

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
public class ListExample {
1414

1515
public static void main(String[] args) {
16-
// TODO Auto-generated method stub
17-
Example1();
16+
//ExampleThree();
17+
iteratingOverAList();
1818
}
1919

20-
public static void Example1() {
20+
public static void ExampleOne() {
2121
List a1 = new ArrayList();
2222
a1.add("one");
2323
a1.add("two");
@@ -37,4 +37,98 @@ public static void Example1() {
3737
System.out.print("\t" + l1);
3838
}
3939

40+
public static void ExampleTwo() {
41+
List<String> list = new ArrayList<String>();
42+
list.add("one");
43+
list.add("two");
44+
list.add("three");
45+
list.add("two");
46+
list.add("two");
47+
48+
List<String> listOne = new ArrayList<String>();
49+
listOne.add("five");
50+
listOne.add("six");
51+
listOne.add("seven");
52+
listOne.add("six");
53+
listOne.add("six");
54+
55+
List<String> listTwo = new ArrayList<String>();
56+
listTwo.addAll(list);
57+
listTwo.addAll(listOne);
58+
59+
Collections.sort(listTwo);
60+
61+
System.out.println(" ArrayList Elements");
62+
System.out.print("\t" + listTwo);
63+
64+
}
65+
66+
public static void ExampleThree() {
67+
List<String> list = new ArrayList<String>();
68+
list.add("one");
69+
list.add("two");
70+
list.add("three");
71+
list.add("four");
72+
list.add("two");
73+
list.add("five");
74+
75+
//list.sort(list);
76+
//modify
77+
list.set(5, "new");
78+
//lambda
79+
//Output : A,B,C,D,E
80+
list.forEach(item->System.out.println(item));
81+
82+
//Output : C
83+
list.forEach(item->{
84+
// if("C".equals(item)){
85+
// System.out.println(item);
86+
// }
87+
System.out.println("item:"+item);
88+
});
89+
90+
//method reference
91+
//Output : A,B,C,D,E
92+
list.forEach(System.out::println);
93+
94+
//Stream and filter
95+
//Output : B
96+
list.stream()
97+
.filter(s->s.contains("B"))
98+
.forEach(System.out::println);
99+
100+
System.out.println(" ArrayList Elements");
101+
System.out.print("\t" + list);
102+
System.out.print(" three: \t" + list.get(2));
103+
//remove
104+
list.removeAll(list);
105+
106+
System.out.print("\t" + list.size());
107+
}
108+
109+
public static void iteratingOverAList() {
110+
List<String> listStrings = new ArrayList<String>();
111+
// OK to add Strings:
112+
listStrings.add("One");
113+
listStrings.add("Two");
114+
listStrings.add("Three");
115+
// But this will cause compile error
116+
//listStrings.add(123);
117+
118+
List<Number> linkedNumbers = new LinkedList<>();
119+
linkedNumbers.add(new Integer(123));
120+
linkedNumbers.add(new Float(3.1415));
121+
linkedNumbers.add(new Double(299.988));
122+
linkedNumbers.add(new Long(67000));
123+
124+
Iterator<String> iterator = listStrings.iterator();
125+
while (iterator.hasNext()) {
126+
System.out.println(iterator.next());
127+
}
128+
129+
// Iterator<Number> iterator = linkedNumbers.listIterator();
130+
// while (iterator.hasNext()) {
131+
// System.out.println(iterator.next());
132+
// }
133+
}
40134
}

src/kevinCollection/QueueExample.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package kevinCollection;
2+
3+
import java.util.LinkedList;
4+
import java.util.Queue;
5+
6+
public class QueueExample {
7+
public static void main(String[] args) {
8+
// TODO Auto-generated method stub
9+
Queue queueA = new LinkedList();
10+
queueA.add("element 0");
11+
queueA.add("element 1");
12+
queueA.add("element 2");
13+
14+
queueA.remove();//element 0
15+
16+
System.out.println(queueA);
17+
}
18+
}

0 commit comments

Comments
 (0)