Skip to content

Commit 412f2d9

Browse files
committed
Cleaning up repo
1 parent 68efb58 commit 412f2d9

25 files changed

+599
-22
lines changed

src/com/deepak/LinkedList/BasicOperations.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/com/deepak/LinkedList/DoublyLinkedList.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/com/deepak/LinkedList/LinkedListConcepts

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/com/deepak/Arrays/BasicOperations.java renamed to src/com/deepak/data/structures/Arrays/BasicOperations.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Data-Structures-And-Algorithms-in-Java
33
*/
4-
package com.deepak.Arrays;
4+
package com.deepak.data.structures.Arrays;
55

66
/**
77
* Class to hold implementation of basic operations in java

src/com/deepak/Hashing/ConcurrentHashMapImplementation.java renamed to src/com/deepak/data/structures/Hashing/ConcurrentHashMapImplementation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Data-Structures-And-Algorithms-in-Java
33
* ConcurrentHashMapImplementation.java
44
*/
5-
package com.deepak.Hashing;
5+
package com.deepak.data.structures.Hashing;
66

77
import java.util.Map;
88
import java.util.concurrent.ConcurrentHashMap;

src/com/deepak/Hashing/ConcurrentModificationException.java renamed to src/com/deepak/data/structures/Hashing/ConcurrentModificationException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Data-Structures-And-Algorithms-in-Java
33
* ConcurrentModificationException.java
44
*/
5-
package com.deepak.Hashing;
5+
package com.deepak.data.structures.Hashing;
66

77
import java.util.HashMap;
88
import java.util.Iterator;

src/com/deepak/Hashing/CustomHashMap.java renamed to src/com/deepak/data/structures/Hashing/CustomHashMap.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Data-Structures-And-Algorithms-in-Java
33
* CustomHashMap.java
44
*/
5-
package com.deepak.Hashing;
5+
package com.deepak.data.structures.Hashing;
66

77
import java.util.Map;
88
import java.util.Objects;
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
package com.deepak.data.structures.Hashing;
2+
3+
import java.util.Map;
4+
import java.util.Objects;
5+
6+
public class CustomHashTable<K, V> {
7+
8+
/**
9+
* This is a node representation of Linked List
10+
* @author Deepak
11+
*
12+
* @param <K>
13+
* @param <V>
14+
*/
15+
static class Entry<K, V> {
16+
final int hash;
17+
final K key;
18+
V value;
19+
Entry<K, V> next;
20+
21+
/**
22+
* Constructor for creating a entry
23+
* @param hash
24+
* @param key
25+
* @param value
26+
* @param next
27+
*/
28+
public Entry(int hash, K key, V value, Entry<K, V> next) {
29+
this.hash = hash;
30+
this.key = key;
31+
this.value = value;
32+
this.next = next;
33+
}
34+
35+
/**
36+
* HashCode implementation for entry
37+
*/
38+
public final int hashCode() {
39+
return Objects.hashCode(key) ^ Objects.hashCode(value);
40+
}
41+
42+
/**
43+
* Method to check if two objects are equal
44+
*/
45+
public final boolean equals(Object o) {
46+
if (o == this) {
47+
return true;
48+
}
49+
if (o instanceof Map.Entry) {
50+
Map.Entry<?,?> e = (Map.Entry<?,?>)o;
51+
if (Objects.equals(key, e.getKey()) &&
52+
Objects.equals(value, e.getValue())) {
53+
return true;
54+
}
55+
}
56+
return false;
57+
}
58+
59+
}
60+
61+
}

0 commit comments

Comments
 (0)