forked from SALychkoEDU/HashTable_Java_template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
75 lines (68 loc) · 1.46 KB
/
Main.java
File metadata and controls
75 lines (68 loc) · 1.46 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
package com.hashtable;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
// write your code here
}
}
class HashTable<T> {
private int size;
private ArrayList<T> table[];
HashTable(int size) {
this.size = size;
table = new ArrayList[size];
for (int i = 0; i < size; i++) {
table[i] = new ArrayList<T>();
}
}
protected int getIndex(T key) {
// Получает индекс по ключу
int hash_key = Math.abs(key.hashCode() % size);
return hash_key;
}
@Override
public String toString() {
StringBuffer str = new StringBuffer();
// Ваш код тут
return str.toString();
}
}
class HashMap<T> extends HashTable<T> {
HashMap(int size) {
super(size);
}
T get(int key) {
return null;
}
void set(int key, T value) {
}
void del(int key) {
}
boolean contains() {
return false;
}
}
class HashSet<T> extends HashTable<T> {
HashSet(int size) {
super(size);
}
T get(int key) {
return null;
}
void set(int key) {
}
void del(int key) {
}
boolean contains() {
return false;
}
HashSet<T> intersection(HashSet<T> setB) {
return null;
}
HashSet<T> difference(HashSet<T> setB) {
return null;
}
HashSet<T> union(HashSet<T> setB) {
return null;
}
}