Skip to content

Commit d559628

Browse files
committed
feat: Slot 클래스 정의 Table의 배열에 속하게 될 원소를 의미
1 parent 5574a7e commit d559628

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package table;
2+
3+
import static table.SlotStatus.DELETED;
4+
import static table.SlotStatus.EMPTY;
5+
import static table.SlotStatus.INUSE;
6+
7+
public class Slot<K, V> {
8+
9+
private K key;
10+
private V value;
11+
private SlotStatus status;
12+
13+
public Slot() {
14+
this.status = EMPTY;
15+
}
16+
17+
public void insertData(K key, V value) {
18+
this.key = key;
19+
this.value = value;
20+
this.status = INUSE;
21+
}
22+
23+
public V deleteData(V value) {
24+
V returnValue = this.value;
25+
this.key = null;
26+
this.value = null;
27+
this.status = DELETED;
28+
return returnValue;
29+
}
30+
31+
public V getValue() {
32+
return this.value;
33+
}
34+
35+
public K getKey() {
36+
return this.key;
37+
}
38+
39+
public SlotStatus getStatus() {
40+
return status;
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package table;
2+
3+
public enum SlotStatus {
4+
EMPTY, DELETED, INUSE
5+
}

0 commit comments

Comments
 (0)