-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashNode.java
More file actions
102 lines (73 loc) · 1.42 KB
/
HashNode.java
File metadata and controls
102 lines (73 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
package Hash;
public class HashNode<K,V extends Comparable<V>> {
private K key;
private V value;
private HashNode<K,V> next;
private HashNode<K,V> previus;
private int size;
public HashNode(K key, V value) {
this.key = key;
this.value = value;
next = null;
previus = null;
size = 1;
}
public K getKey() {
return key;
}
public void setKey(K key) {
this.key = key;
}
public V getValue() {
return value;
}
public void setValue(V value) {
this.value = value;
}
public HashNode<K, V> getNext() {
return next;
}
public void setNext(HashNode<K, V> next) {
this.next = next;
}
public HashNode<K, V> getPrevius() {
return previus;
}
public void setPrevius(HashNode<K, V> previus) {
this.previus = previus;
}
public int getSize() {
return size;
}
public void incrementSize() {
size++;
}
public void add(HashNode<K, V> agregate) {
if(next == null) {
next = agregate;
}else {
next.add(agregate);
}
}
public void romoveLast() {
if(next.getNext() == null) {
next = null;
}else {
next.romoveLast();
}
}
public void incrementSize(int size) {
this.size += size;
}
public HashNode<K, V> getObjet(V value) throws NonexistentKeyException{
if(next != null) {
if(next.value.compareTo(value)== 0) {
return next;
}else {
return next.getObjet(value);
}
}else {
throw new NonexistentKeyException("");
}
}
}